Fix clippy warnings.

This commit fixes the current set of (stable) clippy warnings in the repo.
This commit is contained in:
Peter Huene
2019-10-23 23:15:42 -07:00
committed by Andrew Brown
parent 1176e4f178
commit 9f506692c2
93 changed files with 667 additions and 662 deletions

View File

@@ -15,20 +15,20 @@ pub struct FunctionRunner {
impl FunctionRunner {
/// Build a function runner from a function and the ISA to run on (must be the host machine's ISA)
pub fn new(function: Function, isa: Box<dyn TargetIsa>) -> Self {
FunctionRunner { function, isa }
Self { function, isa }
}
/// Build a function runner using the host machine's ISA and the passed flags
pub fn with_host_isa(function: Function, flags: settings::Flags) -> Self {
let builder = host_isa_builder().expect("Unable to build a TargetIsa for the current host");
let isa = builder.finish(flags);
FunctionRunner::new(function, isa)
Self::new(function, isa)
}
/// Build a function runner using the host machine's ISA and the default flags for this ISA
pub fn with_default_host_isa(function: Function) -> Self {
let flags = settings::Flags::new(settings::builder());
FunctionRunner::with_host_isa(function, flags)
Self::with_host_isa(function, flags)
}
/// Compile and execute a single function, expecting a boolean to be returned; a 'true' value is
@@ -79,9 +79,10 @@ impl FunctionRunner {
let callable_fn: fn() -> bool = unsafe { mem::transmute(code_page.as_ptr()) };
// execute
match callable_fn() {
true => Ok(()),
false => Err(format!("Failed: {}", context.func.name.to_string())),
if callable_fn() {
Ok(())
} else {
Err(format!("Failed: {}", context.func.name.to_string()))
}
}
}

View File

@@ -57,10 +57,10 @@ pub fn run(path: &Path, passes: Option<&[String]>, target: Option<&str>) -> Test
Feature::With(name) => (name, true),
Feature::Without(name) => (name, false),
};
let cranelift_has = match flag {
let cranelift_has = match *flag {
// Add any cranelift feature flag here, and make sure that it is forwarded to the
// cranelift-filetest crate in the top-level Cargo.toml.
&"basic-blocks" => cfg!(feature = "basic-blocks"),
"basic-blocks" => cfg!(feature = "basic-blocks"),
_ => {
return Err(format!(
r#"{:?}: Unknown feature flag named "{}""#,