Skip to content

Commit adeb704

Browse files
nyurikAmanieu
authored andcommitted
Minor linting
1 parent d055c8f commit adeb704

File tree

9 files changed

+13
-22
lines changed

9 files changed

+13
-22
lines changed

crates/intrinsic-test/src/format.rs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,9 @@
33
//! We don't need perfect formatting for the generated tests, but simple indentation can make
44
//! debugging a lot easier.
55
6-
#[derive(Copy, Clone, Debug)]
6+
#[derive(Copy, Clone, Debug, Default)]
77
pub struct Indentation(u32);
88

9-
impl std::default::Default for Indentation {
10-
fn default() -> Self {
11-
Self(0)
12-
}
13-
}
14-
159
impl Indentation {
1610
pub fn nested(self) -> Self {
1711
Self(self.0 + 1)

crates/intrinsic-test/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,7 @@ fn main() {
402402
let args: Cli = clap::Parser::parse();
403403

404404
let filename = args.input;
405-
let c_runner = args.runner.unwrap_or_else(String::new);
405+
let c_runner = args.runner.unwrap_or_default();
406406
let skip = if let Some(filename) = args.skip {
407407
let data = std::fs::read_to_string(&filename).expect("Failed to open file");
408408
data.lines()

crates/intrinsic-test/src/types.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -267,9 +267,9 @@ impl IntrinsicType {
267267
match *self {
268268
IntrinsicType::Type {
269269
kind,
270-
bit_len: Some(bit_len),
270+
bit_len: Some(8),
271271
..
272-
} if bit_len == 8 => match kind {
272+
} => match kind {
273273
TypeKind::Int => "(int)",
274274
TypeKind::UInt => "(unsigned int)",
275275
TypeKind::Poly => "(unsigned int)(uint8_t)",
@@ -318,8 +318,8 @@ impl IntrinsicType {
318318
..
319319
} => {
320320
let (prefix, suffix) = match language {
321-
&Language::Rust => ("[", "]"),
322-
&Language::C => ("{", "}"),
321+
Language::Rust => ("[", "]"),
322+
Language::C => ("{", "}"),
323323
};
324324
let body_indentation = indentation.nested();
325325
format!(

crates/intrinsic-test/src/values.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ pub fn value_for_array(bits: u32, index: u32) -> u64 {
77
8 => VALUES_8[index % VALUES_8.len()].into(),
88
16 => VALUES_16[index % VALUES_16.len()].into(),
99
32 => VALUES_32[index % VALUES_32.len()].into(),
10-
64 => VALUES_64[index % VALUES_64.len()].into(),
10+
64 => VALUES_64[index % VALUES_64.len()],
1111
_ => unimplemented!("value_for_array(bits: {bits}, ..)"),
1212
}
1313
}

crates/std_detect/src/detect/cache.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ cfg_if::cfg_if! {
179179
fn do_initialize(value: Initializer) {
180180
CACHE[0].initialize((value.0) as usize & Cache::MASK);
181181
CACHE[1].initialize((value.0 >> Cache::CAPACITY) as usize & Cache::MASK);
182-
CACHE[2].initialize((value.0 >> 2 * Cache::CAPACITY) as usize & Cache::MASK);
182+
CACHE[2].initialize((value.0 >> (2 * Cache::CAPACITY)) as usize & Cache::MASK);
183183
}
184184

185185
// We only have to detect features once, and it's fairly costly, so hint to LLVM

crates/stdarch-gen-loongarch/src/main.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ fn gen_bind_body(
296296
),
297297
_ => panic!("unsupported parameter number"),
298298
};
299-
format!("fn __{}{} {};", current_name, fn_inputs, fn_output)
299+
format!("fn __{current_name}{fn_inputs} {fn_output};")
300300
};
301301
let function = format!(
302302
r#" #[link_name = "llvm.loongarch.{}"]
@@ -448,7 +448,7 @@ fn gen_bind_body(
448448
};
449449
rustc_legacy_const_generics = "rustc_legacy_const_generics(2, 3)";
450450
}
451-
format!("pub unsafe fn {}{} {}", current_name, fn_inputs, fn_output)
451+
format!("pub unsafe fn {current_name}{fn_inputs} {fn_output}")
452452
};
453453
let mut call_params = {
454454
match para_num {

crates/stdarch-test/src/disassembly.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ fn parse(output: &str) -> HashSet<Function> {
169169
}
170170
}
171171
match (parts.first(), parts.last()) {
172-
(Some(instr), Some(last_arg)) if is_shll(&instr) && last_arg == "#0" => {
172+
(Some(instr), Some(last_arg)) if is_shll(instr) && last_arg == "#0" => {
173173
assert_eq!(parts.len(), 4);
174174
let mut new_parts = Vec::with_capacity(3);
175175
let new_instr = format!("{}{}{}", &instr[..1], "xtl", &instr[5..]);

crates/stdarch-test/src/lib.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -169,10 +169,7 @@ pub fn assert(shim_addr: usize, fnname: &str, expected: &str) {
169169
}
170170

171171
if !found {
172-
panic!(
173-
"failed to find instruction `{}` in the disassembly",
174-
expected
175-
);
172+
panic!("failed to find instruction `{expected}` in the disassembly");
176173
} else if !probably_only_one_instruction {
177174
panic!(
178175
"instruction found, but the disassembly contains too many \

crates/stdarch-verify/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -535,7 +535,7 @@ fn find_doc(attrs: &[syn::Attribute]) -> String {
535535
}
536536
}
537537
}
538-
return None;
538+
None
539539
})
540540
.collect()
541541
}

0 commit comments

Comments
 (0)