diff --git a/crates/intrinsic-test/src/format.rs b/crates/intrinsic-test/src/format.rs index fd185fb748..9ee331d7f7 100644 --- a/crates/intrinsic-test/src/format.rs +++ b/crates/intrinsic-test/src/format.rs @@ -3,15 +3,9 @@ //! We don't need perfect formatting for the generated tests, but simple indentation can make //! debugging a lot easier. -#[derive(Copy, Clone, Debug)] +#[derive(Copy, Clone, Debug, Default)] pub struct Indentation(u32); -impl std::default::Default for Indentation { - fn default() -> Self { - Self(0) - } -} - impl Indentation { pub fn nested(self) -> Self { Self(self.0 + 1) diff --git a/crates/intrinsic-test/src/main.rs b/crates/intrinsic-test/src/main.rs index eefb5f921a..58966d230c 100644 --- a/crates/intrinsic-test/src/main.rs +++ b/crates/intrinsic-test/src/main.rs @@ -402,7 +402,7 @@ fn main() { let args: Cli = clap::Parser::parse(); let filename = args.input; - let c_runner = args.runner.unwrap_or_else(String::new); + let c_runner = args.runner.unwrap_or_default(); let skip = if let Some(filename) = args.skip { let data = std::fs::read_to_string(&filename).expect("Failed to open file"); data.lines() diff --git a/crates/intrinsic-test/src/types.rs b/crates/intrinsic-test/src/types.rs index a3db342ae2..594fe4d2d2 100644 --- a/crates/intrinsic-test/src/types.rs +++ b/crates/intrinsic-test/src/types.rs @@ -267,9 +267,9 @@ impl IntrinsicType { match *self { IntrinsicType::Type { kind, - bit_len: Some(bit_len), + bit_len: Some(8), .. - } if bit_len == 8 => match kind { + } => match kind { TypeKind::Int => "(int)", TypeKind::UInt => "(unsigned int)", TypeKind::Poly => "(unsigned int)(uint8_t)", @@ -318,8 +318,8 @@ impl IntrinsicType { .. } => { let (prefix, suffix) = match language { - &Language::Rust => ("[", "]"), - &Language::C => ("{", "}"), + Language::Rust => ("[", "]"), + Language::C => ("{", "}"), }; let body_indentation = indentation.nested(); format!( diff --git a/crates/intrinsic-test/src/values.rs b/crates/intrinsic-test/src/values.rs index 1a69a034c8..1b614a742e 100644 --- a/crates/intrinsic-test/src/values.rs +++ b/crates/intrinsic-test/src/values.rs @@ -7,7 +7,7 @@ pub fn value_for_array(bits: u32, index: u32) -> u64 { 8 => VALUES_8[index % VALUES_8.len()].into(), 16 => VALUES_16[index % VALUES_16.len()].into(), 32 => VALUES_32[index % VALUES_32.len()].into(), - 64 => VALUES_64[index % VALUES_64.len()].into(), + 64 => VALUES_64[index % VALUES_64.len()], _ => unimplemented!("value_for_array(bits: {bits}, ..)"), } } diff --git a/crates/std_detect/src/detect/cache.rs b/crates/std_detect/src/detect/cache.rs index 643e4da194..cee07b0ec7 100644 --- a/crates/std_detect/src/detect/cache.rs +++ b/crates/std_detect/src/detect/cache.rs @@ -179,7 +179,7 @@ cfg_if::cfg_if! { fn do_initialize(value: Initializer) { CACHE[0].initialize((value.0) as usize & Cache::MASK); CACHE[1].initialize((value.0 >> Cache::CAPACITY) as usize & Cache::MASK); - CACHE[2].initialize((value.0 >> 2 * Cache::CAPACITY) as usize & Cache::MASK); + CACHE[2].initialize((value.0 >> (2 * Cache::CAPACITY)) as usize & Cache::MASK); } // We only have to detect features once, and it's fairly costly, so hint to LLVM diff --git a/crates/stdarch-gen-loongarch/src/main.rs b/crates/stdarch-gen-loongarch/src/main.rs index 47bc9a1074..cd37c025b5 100644 --- a/crates/stdarch-gen-loongarch/src/main.rs +++ b/crates/stdarch-gen-loongarch/src/main.rs @@ -296,7 +296,7 @@ fn gen_bind_body( ), _ => panic!("unsupported parameter number"), }; - format!("fn __{}{} {};", current_name, fn_inputs, fn_output) + format!("fn __{current_name}{fn_inputs} {fn_output};") }; let function = format!( r#" #[link_name = "llvm.loongarch.{}"] @@ -448,7 +448,7 @@ fn gen_bind_body( }; rustc_legacy_const_generics = "rustc_legacy_const_generics(2, 3)"; } - format!("pub unsafe fn {}{} {}", current_name, fn_inputs, fn_output) + format!("pub unsafe fn {current_name}{fn_inputs} {fn_output}") }; let mut call_params = { match para_num { diff --git a/crates/stdarch-test/src/disassembly.rs b/crates/stdarch-test/src/disassembly.rs index cb6c008a71..a7b46a73fc 100644 --- a/crates/stdarch-test/src/disassembly.rs +++ b/crates/stdarch-test/src/disassembly.rs @@ -169,7 +169,7 @@ fn parse(output: &str) -> HashSet { } } match (parts.first(), parts.last()) { - (Some(instr), Some(last_arg)) if is_shll(&instr) && last_arg == "#0" => { + (Some(instr), Some(last_arg)) if is_shll(instr) && last_arg == "#0" => { assert_eq!(parts.len(), 4); let mut new_parts = Vec::with_capacity(3); let new_instr = format!("{}{}{}", &instr[..1], "xtl", &instr[5..]); diff --git a/crates/stdarch-test/src/lib.rs b/crates/stdarch-test/src/lib.rs index a2835e3b0c..3248de8f3a 100644 --- a/crates/stdarch-test/src/lib.rs +++ b/crates/stdarch-test/src/lib.rs @@ -169,10 +169,7 @@ pub fn assert(shim_addr: usize, fnname: &str, expected: &str) { } if !found { - panic!( - "failed to find instruction `{}` in the disassembly", - expected - ); + panic!("failed to find instruction `{expected}` in the disassembly"); } else if !probably_only_one_instruction { panic!( "instruction found, but the disassembly contains too many \ diff --git a/crates/stdarch-verify/src/lib.rs b/crates/stdarch-verify/src/lib.rs index 1afb556aab..5e4db96a70 100644 --- a/crates/stdarch-verify/src/lib.rs +++ b/crates/stdarch-verify/src/lib.rs @@ -535,7 +535,7 @@ fn find_doc(attrs: &[syn::Attribute]) -> String { } } } - return None; + None }) .collect() }