Address all clippy lints

These changes do not change the behaviour of the
code and should be non-controversial.
This commit is contained in:
Alexander Theißen
2020-10-13 13:44:05 +02:00
parent f59eb121e5
commit c09a924a81
18 changed files with 249 additions and 256 deletions
+9 -9
View File
@@ -28,12 +28,12 @@ pub enum Error {
impl std::fmt::Display for Error {
fn fmt(&self, f: &mut std::fmt::Formatter) -> Result<(), std::fmt::Error> {
use self::Error::*;
match *self {
Io(ref io) => write!(f, "Generic i/o error: {}", io),
FailedToCopy(ref msg) => write!(f, "{}. Have you tried to run \"cargo build\"?", msg),
Decoding(ref err, ref file) => write!(f, "Decoding error ({}). Must be a valid wasm file {}. Pointed wrong file?", err, file),
Encoding(ref err) => write!(f, "Encoding error ({}). Almost impossible to happen, no free disk space?", err),
Build(ref err) => write!(f, "Build error: {}", err)
match self {
Io(io) => write!(f, "Generic i/o error: {}", io),
FailedToCopy(msg) => write!(f, "{}. Have you tried to run \"cargo build\"?", msg),
Decoding(err, file) => write!(f, "Decoding error ({}). Must be a valid wasm file {}. Pointed wrong file?", err, file),
Encoding(err) => write!(f, "Encoding error ({}). Almost impossible to happen, no free disk space?", err),
Build(err) => write!(f, "Build error: {}", err)
}
}
}
@@ -163,9 +163,9 @@ fn do_main() -> Result<(), Error> {
None
};
let public_api_entries = matches.value_of("public_api")
.map(|val| val.split(",").collect())
.unwrap_or(Vec::new());
let public_api_entries: Vec<_> = matches.value_of("public_api")
.map(|val| val.split(',').collect())
.unwrap_or_default();
let target_runtime = match matches.value_of("target-runtime").expect("target-runtime has a default value; qed") {
"pwasm" => TargetRuntime::pwasm(),
+2 -2
View File
@@ -17,8 +17,8 @@ pub struct SourceInput<'a> {
impl<'a> SourceInput<'a> {
pub fn new<'b>(target_dir: &'b str, bin_name: &'b str) -> SourceInput<'b> {
SourceInput {
target_dir: target_dir,
bin_name: bin_name,
target_dir,
bin_name,
final_name: bin_name,
target: SourceTarget::Emscripten,
}
+4 -4
View File
@@ -11,7 +11,7 @@ fn fail(msg: &str) -> ! {
std::process::exit(1)
}
const ALLOWED_IMPORTS: &'static [&'static str] = &[
const ALLOWED_IMPORTS: &[&str] = &[
"ret",
"storage_read",
"storage_write",
@@ -54,14 +54,14 @@ fn main() {
let module = parity_wasm::deserialize_file(&input).expect("Input module deserialization failed");
for section in module.sections() {
match *section {
elements::Section::Import(ref import_section) => {
match section {
elements::Section::Import(import_section) => {
let mut has_imported_memory_properly_named = false;
for entry in import_section.entries() {
if entry.module() != "env" {
fail("All imports should be from env");
}
match *entry.external() {
match entry.external() {
elements::External::Function(_) => {
if !ALLOWED_IMPORTS.contains(&entry.field()) {
fail(&format!("'{}' is not supported by the runtime", entry.field()));