Skip to content

Commit 58d85a5

Browse files
feat: code cleanup 1. changing array bracket prefixes from &'static str
to char 2. including variable names in template strings instead of passing them as arguments to macros
1 parent 1646a8b commit 58d85a5

File tree

5 files changed

+25
-25
lines changed

5 files changed

+25
-25
lines changed

crates/intrinsic-test/src/arm/types.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ impl IntrinsicTypeDefinition for ArmIntrinsicType {
1414
(None, None) => format!("{const_prefix}{prefix}{bit_len}_t"),
1515
(Some(simd), None) => format!("{prefix}{bit_len}x{simd}_t"),
1616
(Some(simd), Some(vec)) => format!("{prefix}{bit_len}x{simd}x{vec}_t"),
17-
(None, Some(_)) => todo!("{:#?}", self), // Likely an invalid case
17+
(None, Some(_)) => todo!("{self:#?}"), // Likely an invalid case
1818
}
1919
} else {
20-
todo!("{:#?}", self)
20+
todo!("{self:#?}")
2121
}
2222
}
2323

@@ -58,14 +58,14 @@ impl IntrinsicTypeDefinition for ArmIntrinsicType {
5858
// The ACLE doesn't support 64-bit polynomial loads on Armv7
5959
// if armv7 and bl == 64, use "s", else "p"
6060
TypeKind::Poly => if choose_workaround && *bl == 64 {"s"} else {"p"},
61-
x => todo!("get_load_function TypeKind: {:#?}", x),
61+
x => todo!("get_load_function TypeKind: {x:#?}"),
6262
},
6363
size = bl,
6464
quad = quad,
6565
len = vec_len.unwrap_or(1),
6666
)
6767
} else {
68-
todo!("get_load_function IntrinsicType: {:#?}", self)
68+
todo!("get_load_function IntrinsicType: {self:#?}")
6969
}
7070
}
7171

@@ -90,13 +90,13 @@ impl IntrinsicTypeDefinition for ArmIntrinsicType {
9090
TypeKind::Int(Sign::Signed) => "s",
9191
TypeKind::Float => "f",
9292
TypeKind::Poly => "p",
93-
x => todo!("get_load_function TypeKind: {:#?}", x),
93+
x => todo!("get_load_function TypeKind: {x:#?}"),
9494
},
9595
size = bl,
9696
quad = quad,
9797
)
9898
} else {
99-
todo!("get_lane_function IntrinsicType: {:#?}", self)
99+
todo!("get_lane_function IntrinsicType: {self:#?}")
100100
}
101101
}
102102

@@ -143,7 +143,7 @@ impl IntrinsicTypeDefinition for ArmIntrinsicType {
143143
TypeKind::Int(Sign::Signed) => format!("int{}_t", self.inner_size()),
144144
TypeKind::Int(Sign::Unsigned) => format!("uint{}_t", self.inner_size()),
145145
TypeKind::Poly => format!("poly{}_t", self.inner_size()),
146-
ty => todo!("print_result_c - Unknown type: {:#?}", ty),
146+
ty => todo!("print_result_c - Unknown type: {ty:#?}"),
147147
},
148148
promote = self.generate_final_type_cast(),
149149
)

crates/intrinsic-test/src/common/argument.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ where
3131

3232
pub fn to_c_type(&self) -> String {
3333
let prefix = if self.ty.constant { "const " } else { "" };
34-
format!("{}{}", prefix, self.ty.c_type())
34+
format!("{prefix}{}", self.ty.c_type())
3535
}
3636

3737
pub fn generate_name(&self) -> String {

crates/intrinsic-test/src/common/intrinsic_helpers.rs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ impl TypeKind {
8080
Self::Poly => "poly",
8181
Self::Char(Sign::Signed) => "char",
8282
Self::Vector => "int",
83-
_ => unreachable!("Not used: {:#?}", self),
83+
_ => unreachable!("Not used: {self:#?}"),
8484
}
8585
}
8686

@@ -94,7 +94,7 @@ impl TypeKind {
9494
Self::Poly => "u",
9595
Self::Char(Sign::Unsigned) => "u",
9696
Self::Char(Sign::Signed) => "i",
97-
_ => unreachable!("Unused type kind: {:#?}", self),
97+
_ => unreachable!("Unused type kind: {self:#?}"),
9898
}
9999
}
100100
}
@@ -134,7 +134,7 @@ impl IntrinsicType {
134134
if let Some(bl) = self.bit_len {
135135
cmp::max(bl, 8)
136136
} else {
137-
unreachable!("{:#?}", self)
137+
unreachable!("{self:#?}")
138138
}
139139
}
140140

@@ -225,8 +225,8 @@ impl IntrinsicType {
225225
..
226226
} => {
227227
let (prefix, suffix) = match language {
228-
Language::Rust => ("[", "]"),
229-
Language::C => ("{", "}"),
228+
Language::Rust => ('[', ']'),
229+
Language::C => ('{', '}'),
230230
};
231231
let body_indentation = indentation.nested();
232232
format!(
@@ -262,12 +262,12 @@ impl IntrinsicType {
262262
..
263263
} => {
264264
let (prefix, cast_prefix, cast_suffix, suffix) = match (language, bit_len) {
265-
(&Language::Rust, 16) => ("[", "f16::from_bits(", ")", "]"),
266-
(&Language::Rust, 32) => ("[", "f32::from_bits(", ")", "]"),
267-
(&Language::Rust, 64) => ("[", "f64::from_bits(", ")", "]"),
268-
(&Language::C, 16) => ("{", "cast<float16_t, uint16_t>(", ")", "}"),
269-
(&Language::C, 32) => ("{", "cast<float, uint32_t>(", ")", "}"),
270-
(&Language::C, 64) => ("{", "cast<double, uint64_t>(", ")", "}"),
265+
(&Language::Rust, 16) => ('[', "f16::from_bits(", ")", ']'),
266+
(&Language::Rust, 32) => ('[', "f32::from_bits(", ")", ']'),
267+
(&Language::Rust, 64) => ('[', "f64::from_bits(", ")", ']'),
268+
(&Language::C, 16) => ('{', "cast<float16_t, uint16_t>(", ")", '}'),
269+
(&Language::C, 32) => ('{', "cast<float, uint32_t>(", ")", '}'),
270+
(&Language::C, 64) => ('{', "cast<double, uint64_t>(", ")", '}'),
271271
_ => unreachable!(),
272272
};
273273
format!(
@@ -288,8 +288,8 @@ impl IntrinsicType {
288288
..
289289
} => {
290290
let (prefix, suffix) = match language {
291-
Language::Rust => ("[", "]"),
292-
Language::C => ("{", "}"),
291+
Language::Rust => ('[', ']'),
292+
Language::C => ('{', '}'),
293293
};
294294
let body_indentation = indentation.nested();
295295
let effective_bit_len = 32;
@@ -317,7 +317,7 @@ impl IntrinsicType {
317317
})
318318
)
319319
}
320-
_ => unimplemented!("populate random: {:#?}", self),
320+
_ => unimplemented!("populate random: {self:#?}"),
321321
}
322322
}
323323

crates/intrinsic-test/src/x86/config.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ trait DebugAs<T> {
213213
214214
impl<T: core::fmt::Display> DebugAs<T> for T {
215215
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
216-
write!(f, "{}", self)
216+
write!(f, "{self}")
217217
}
218218
}
219219

crates/intrinsic-test/src/x86/types.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -219,11 +219,11 @@ impl IntrinsicTypeDefinition for X86IntrinsicType {
219219
TypeKind::Float if self.inner_size() == 32 => "float".to_string(),
220220
TypeKind::Mask => format!(
221221
"__mmask{}",
222-
self.bit_len.expect(format!("self: {:#?}", self).as_str())
222+
self.bit_len.expect(format!("self: {self:#?}").as_str())
223223
),
224224
TypeKind::Vector => format!(
225225
"__m{}i",
226-
self.bit_len.expect(format!("self: {:#?}", self).as_str())
226+
self.bit_len.expect(format!("self: {self:#?}").as_str())
227227
),
228228
_ => self.c_scalar_type(),
229229
},

0 commit comments

Comments
 (0)