Skip to content

Commit 72ed909

Browse files
nyurikAmanieu
authored andcommitted
Minor lints for stdarch-gen-arm/src/main.rs
Just a few minor cleanups
1 parent 09d1bd0 commit 72ed909

File tree

1 file changed

+14
-26
lines changed

1 file changed

+14
-26
lines changed

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

Lines changed: 14 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -684,8 +684,8 @@ impl From<Vec<String>> for Lines {
684684
}
685685
}
686686

687-
impl std::fmt::Display for Lines {
688-
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> fmt::Result {
687+
impl fmt::Display for Lines {
688+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
689689
for line in self.lines.iter() {
690690
write!(f, "\n{:width$}{line}", "", width = self.indent)?;
691691
}
@@ -1182,11 +1182,7 @@ fn type_to_ext(t: &str, v: bool, r: bool, pi8: bool) -> String {
11821182
let native = type_to_native_type(t);
11831183
let sub_ext = match type_sub_len(t) {
11841184
1 => String::new(),
1185-
_ if v => format!(
1186-
".p0v{}{}",
1187-
&type_len(&type_to_sub_type(t)).to_string(),
1188-
native
1189-
),
1185+
_ if v => format!(".p0v{}{native}", type_len(&type_to_sub_type(t))),
11901186
_ if pi8 => ".p0i8".to_string(),
11911187
_ => format!(".p0{native}"),
11921188
};
@@ -1195,12 +1191,7 @@ fn type_to_ext(t: &str, v: bool, r: bool, pi8: bool) -> String {
11951191
"u" => native.replace('u', "i"),
11961192
_ => panic!("unknown type: {t}"),
11971193
};
1198-
let ext = format!(
1199-
"v{}{}{}",
1200-
&type_len(&type_to_sub_type(t)).to_string(),
1201-
sub_type,
1202-
sub_ext
1203-
);
1194+
let ext = format!("v{}{sub_type}{sub_ext}", type_len(&type_to_sub_type(t)));
12041195
if r {
12051196
let ss: Vec<_> = ext.split('.').collect();
12061197
if ss.len() != 2 {
@@ -2800,7 +2791,7 @@ fn get_call(
28002791
if i != 0 || j != 0 {
28012792
s.push_str(", ");
28022793
}
2803-
s.push_str(&format!("{base_len} * {} as u32", &fn_format[2]));
2794+
s.push_str(&format!("{base_len} * {} as u32", fn_format[2]));
28042795
if j != 0 {
28052796
s.push_str(&format!(" + {j}"));
28062797
}
@@ -2816,7 +2807,7 @@ fn get_call(
28162807
"in_ttn" => type_to_native_type(in_t[1]),
28172808
_ => String::new(),
28182809
};
2819-
return format!("{} as {t}", &fn_format[1]);
2810+
return format!("{} as {t}", fn_format[1]);
28202811
}
28212812
if fn_name.starts_with("ins") {
28222813
let fn_format: Vec<_> = fn_name.split('-').map(|v| v.to_string()).collect();
@@ -2861,11 +2852,11 @@ fn get_call(
28612852
"in2_dot" => type_exp_len(in_t[2], 4),
28622853
_ => 0,
28632854
};
2864-
if len == 0 {
2865-
return format!(r#"static_assert!({} == 0);"#, fn_format[2]);
2855+
return if len == 0 {
2856+
format!(r#"static_assert!({} == 0);"#, fn_format[2])
28662857
} else {
2867-
return format!(r#"static_assert_uimm_bits!({}, {len});"#, fn_format[2]);
2868-
}
2858+
format!(r#"static_assert_uimm_bits!({}, {len});"#, fn_format[2])
2859+
};
28692860
}
28702861
if fn_name.starts_with("static_assert") {
28712862
let fn_format: Vec<_> = fn_name.split('-').map(|v| v.to_string()).collect();
@@ -3175,22 +3166,19 @@ fn get_call(
31753166
} else {
31763167
String::from(&types[1])
31773168
};
3178-
fn_name.push_str(&format!("::<{}, {}>", &type1, &type2));
3169+
fn_name.push_str(&format!("::<{type1}, {type2}>"));
31793170
} else {
31803171
fn_name.push_str(&fn_format[2]);
31813172
}
31823173
}
31833174
if param_str.is_empty() {
31843175
fn_name.replace("out_t", out_t)
31853176
} else if let Some((re_name, re_type)) = re.clone() {
3186-
format!(
3187-
r#"let {}: {} = {}({});"#,
3188-
re_name, re_type, fn_name, param_str
3189-
)
3177+
format!("let {re_name}: {re_type} = {fn_name}({param_str});")
31903178
} else if fn_name.starts_with('*') {
3191-
format!(r#"{fn_name} = {param_str};"#)
3179+
format!("{fn_name} = {param_str};")
31923180
} else {
3193-
format!(r#"{fn_name}({param_str})"#)
3181+
format!("{fn_name}({param_str})")
31943182
}
31953183
}
31963184

0 commit comments

Comments
 (0)