Skip to content

Commit e3c5212

Browse files
committed
Clippy fixes
1 parent e4c885e commit e3c5212

File tree

32 files changed

+197
-252
lines changed

32 files changed

+197
-252
lines changed

crates/rustc_codegen_spirv-types/src/compile_result.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ impl<'a> Trie<'a> {
7474
let full_child_name = if full_name.is_empty() {
7575
(*child_name).to_string()
7676
} else {
77-
format!("{}::{}", full_name, child_name)
77+
format!("{full_name}::{child_name}")
7878
};
7979
if child.present {
8080
assert!(child.children.is_empty());

crates/rustc_codegen_spirv/build.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ fn main() -> ExitCode {
7878
match check_toolchain_version() {
7979
Ok(_) => ExitCode::SUCCESS,
8080
Err(e) => {
81-
eprint!("{}", e);
81+
eprint!("{e}");
8282
ExitCode::FAILURE
8383
}
8484
}

crates/rustc_codegen_spirv/src/abi.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ impl fmt::Display for PointeeTy<'_> {
270270
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
271271
match self {
272272
PointeeTy::Ty(ty) => write!(f, "{}", ty.ty),
273-
PointeeTy::Fn(ty) => write!(f, "{}", ty),
273+
PointeeTy::Fn(ty) => write!(f, "{ty}"),
274274
}
275275
}
276276
}
@@ -577,8 +577,7 @@ fn dig_scalar_pointee<'tcx>(
577577
Some(old_pointee) if old_pointee != new_pointee => {
578578
cx.tcx.sess.fatal(format!(
579579
"dig_scalar_pointee: unsupported Pointer with different \
580-
pointee types ({:?} vs {:?}) at offset {:?} in {:#?}",
581-
old_pointee, new_pointee, offset, layout
580+
pointee types ({old_pointee:?} vs {new_pointee:?}) at offset {offset:?} in {layout:#?}"
582581
));
583582
}
584583
_ => pointee = Some(new_pointee),
@@ -860,7 +859,7 @@ fn trans_intrinsic_type<'tcx>(
860859
None => Err(cx
861860
.tcx
862861
.sess
863-
.err(format!("Invalid value for Image const generic: {}", value))),
862+
.err(format!("Invalid value for Image const generic: {value}"))),
864863
}
865864
}
866865

crates/rustc_codegen_spirv/src/attr.rs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ impl AggregatedSpirvAttributes {
158158
}) => {
159159
cx.tcx
160160
.sess
161-
.delay_span_bug(span, format!("multiple {} attributes", category));
161+
.delay_span_bug(span, format!("multiple {category} attributes"));
162162
}
163163
}
164164
}
@@ -333,7 +333,7 @@ impl CheckSpirvAttrVisitor<'_> {
333333
if let Err(msg) = valid {
334334
self.tcx.sess.span_err(
335335
span,
336-
format!("`{:?}` storage class {}", storage_class, msg),
336+
format!("`{storage_class:?}` storage class {msg}"),
337337
);
338338
}
339339
}
@@ -355,8 +355,7 @@ impl CheckSpirvAttrVisitor<'_> {
355355
self.tcx.sess.span_err(
356356
span,
357357
format!(
358-
"attribute is only valid on a {}, not on a {}",
359-
expected_target, target
358+
"attribute is only valid on a {expected_target}, not on a {target}"
360359
),
361360
);
362361
}
@@ -371,11 +370,10 @@ impl CheckSpirvAttrVisitor<'_> {
371370
.struct_span_err(
372371
span,
373372
&format!(
374-
"only one {} attribute is allowed on a {}",
375-
category, target
373+
"only one {category} attribute is allowed on a {target}"
376374
),
377375
)
378-
.span_note(prev_span, &format!("previous {} attribute", category))
376+
.span_note(prev_span, &format!("previous {category} attribute"))
379377
.emit();
380378
}
381379
},

crates/rustc_codegen_spirv/src/builder/builder_methods.rs

Lines changed: 29 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -193,8 +193,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
193193
.constant_u64(self.span(), memset_fill_u64(fill_byte))
194194
.def(self),
195195
_ => self.fatal(&format!(
196-
"memset on integer width {} not implemented yet",
197-
width
196+
"memset on integer width {width} not implemented yet"
198197
)),
199198
},
200199
SpirvType::Float(width) => match width {
@@ -205,8 +204,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
205204
.constant_f64(self.span(), f64::from_bits(memset_fill_u64(fill_byte)))
206205
.def(self),
207206
_ => self.fatal(&format!(
208-
"memset on float width {} not implemented yet",
209-
width
207+
"memset on float width {width} not implemented yet"
210208
)),
211209
},
212210
SpirvType::Adt { .. } => self.fatal("memset on structs not implemented yet"),
@@ -253,16 +251,14 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
253251
32 => memset_dynamic_scalar(self, fill_var, 4, false),
254252
64 => memset_dynamic_scalar(self, fill_var, 8, false),
255253
_ => self.fatal(&format!(
256-
"memset on integer width {} not implemented yet",
257-
width
254+
"memset on integer width {width} not implemented yet"
258255
)),
259256
},
260257
SpirvType::Float(width) => match width {
261258
32 => memset_dynamic_scalar(self, fill_var, 4, true),
262259
64 => memset_dynamic_scalar(self, fill_var, 8, true),
263260
_ => self.fatal(&format!(
264-
"memset on float width {} not implemented yet",
265-
width
261+
"memset on float width {width} not implemented yet"
266262
)),
267263
},
268264
SpirvType::Adt { .. } => self.fatal("memset on structs not implemented yet"),
@@ -367,7 +363,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
367363
if !self.builder.has_capability(Capability::VariablePointers) {
368364
self.zombie(
369365
def,
370-
&format!("{} without OpCapability VariablePointers", inst),
366+
&format!("{inst} without OpCapability VariablePointers"),
371367
);
372368
}
373369
}
@@ -725,8 +721,7 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> {
725721
fn construct_8(self_: &Builder<'_, '_>, signed: bool, v: u128) -> Operand {
726722
if v > u8::MAX as u128 {
727723
self_.fatal(&format!(
728-
"Switches to values above u8::MAX not supported: {:?}",
729-
v
724+
"Switches to values above u8::MAX not supported: {v:?}"
730725
))
731726
} else if signed {
732727
// this cast chain can probably be collapsed, but, whatever, be safe
@@ -738,8 +733,7 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> {
738733
fn construct_16(self_: &Builder<'_, '_>, signed: bool, v: u128) -> Operand {
739734
if v > u16::MAX as u128 {
740735
self_.fatal(&format!(
741-
"Switches to values above u16::MAX not supported: {:?}",
742-
v
736+
"Switches to values above u16::MAX not supported: {v:?}"
743737
))
744738
} else if signed {
745739
Operand::LiteralInt32(v as u16 as i16 as i32 as u32)
@@ -750,8 +744,7 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> {
750744
fn construct_32(self_: &Builder<'_, '_>, _signed: bool, v: u128) -> Operand {
751745
if v > u32::MAX as u128 {
752746
self_.fatal(&format!(
753-
"Switches to values above u32::MAX not supported: {:?}",
754-
v
747+
"Switches to values above u32::MAX not supported: {v:?}"
755748
))
756749
} else {
757750
Operand::LiteralInt32(v as u32)
@@ -760,8 +753,7 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> {
760753
fn construct_64(self_: &Builder<'_, '_>, _signed: bool, v: u128) -> Operand {
761754
if v > u64::MAX as u128 {
762755
self_.fatal(&format!(
763-
"Switches to values above u64::MAX not supported: {:?}",
764-
v
756+
"Switches to values above u64::MAX not supported: {v:?}"
765757
))
766758
} else {
767759
Operand::LiteralInt64(v as u64)
@@ -776,8 +768,7 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> {
776768
32 => construct_32,
777769
64 => construct_64,
778770
other => self.fatal(&format!(
779-
"switch selector cannot have width {} (only 8, 16, 32, and 64 bits allowed)",
780-
other
771+
"switch selector cannot have width {other} (only 8, 16, 32, and 64 bits allowed)"
781772
)),
782773
};
783774
(signed, construct_case)
@@ -1025,8 +1016,7 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> {
10251016
pointee
10261017
}
10271018
ty => self.fatal(&format!(
1028-
"load called on variable that wasn't a pointer: {:?}",
1029-
ty
1019+
"load called on variable that wasn't a pointer: {ty:?}"
10301020
)),
10311021
};
10321022
self.emit()
@@ -1055,8 +1045,7 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> {
10551045
pointee
10561046
}
10571047
ty => self.fatal(&format!(
1058-
"atomic_load called on variable that wasn't a pointer: {:?}",
1059-
ty
1048+
"atomic_load called on variable that wasn't a pointer: {ty:?}"
10601049
)),
10611050
};
10621051
// TODO: Default to device scope
@@ -1135,7 +1124,7 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> {
11351124
let start = dest.project_index(self, zero).llval;
11361125

11371126
let elem_layout = dest.layout.field(self.cx(), 0);
1138-
let elem_ty = elem_layout.spirv_type(self.span(), &self);
1127+
let elem_ty = elem_layout.spirv_type(self.span(), self);
11391128
let align = dest.align.restrict_for_offset(elem_layout.size);
11401129

11411130
for i in 0..count {
@@ -1159,8 +1148,7 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> {
11591148
let ptr_elem_ty = match self.lookup_type(ptr.ty) {
11601149
SpirvType::Pointer { pointee } => pointee,
11611150
ty => self.fatal(&format!(
1162-
"store called on variable that wasn't a pointer: {:?}",
1163-
ty
1151+
"store called on variable that wasn't a pointer: {ty:?}"
11641152
)),
11651153
};
11661154

@@ -1192,8 +1180,7 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> {
11921180
) -> Self::Value {
11931181
if flags != MemFlags::empty() {
11941182
self.err(&format!(
1195-
"store_with_flags is not supported yet: {:?}",
1196-
flags
1183+
"store_with_flags is not supported yet: {flags:?}"
11971184
));
11981185
}
11991186
self.store(val, ptr, align)
@@ -1209,8 +1196,7 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> {
12091196
let ptr_elem_ty = match self.lookup_type(ptr.ty) {
12101197
SpirvType::Pointer { pointee } => pointee,
12111198
ty => self.fatal(&format!(
1212-
"atomic_store called on variable that wasn't a pointer: {:?}",
1213-
ty
1199+
"atomic_store called on variable that wasn't a pointer: {ty:?}"
12141200
)),
12151201
};
12161202
assert_ty_eq!(self, ptr_elem_ty, val.ty);
@@ -1248,8 +1234,7 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> {
12481234
pointee
12491235
}
12501236
other => self.fatal(&format!(
1251-
"struct_gep not on pointer type: {:?}, index {}",
1252-
other, idx
1237+
"struct_gep not on pointer type: {other:?}, index {idx}"
12531238
)),
12541239
};
12551240
let pointee_kind = self.lookup_type(pointee);
@@ -1264,8 +1249,7 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> {
12641249
inner_type
12651250
}
12661251
other => self.fatal(&format!(
1267-
"struct_gep not on struct, array, or vector type: {:?}, index {}",
1268-
other, idx
1252+
"struct_gep not on struct, array, or vector type: {other:?}, index {idx}"
12691253
)),
12701254
};
12711255
let result_type = SpirvType::Pointer {
@@ -1410,8 +1394,7 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> {
14101394
match self.lookup_type(val.ty) {
14111395
SpirvType::Pointer { .. } => (),
14121396
other => self.fatal(&format!(
1413-
"ptrtoint called on non-pointer source type: {:?}",
1414-
other
1397+
"ptrtoint called on non-pointer source type: {other:?}"
14151398
)),
14161399
}
14171400
if val.ty == dest_ty {
@@ -1431,8 +1414,7 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> {
14311414
match self.lookup_type(dest_ty) {
14321415
SpirvType::Pointer { .. } => (),
14331416
other => self.fatal(&format!(
1434-
"inttoptr called on non-pointer dest type: {:?}",
1435-
other
1417+
"inttoptr called on non-pointer dest type: {other:?}"
14361418
)),
14371419
}
14381420
if val.ty == dest_ty {
@@ -1540,8 +1522,7 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> {
15401522
.with_type(dest_ty)
15411523
}
15421524
(val_ty, dest_ty_spv) => self.fatal(&format!(
1543-
"TODO: intcast not implemented yet: val={:?} val.ty={:?} dest_ty={:?} is_signed={}",
1544-
val, val_ty, dest_ty_spv, is_signed
1525+
"TODO: intcast not implemented yet: val={val:?} val.ty={val_ty:?} dest_ty={dest_ty_spv:?} is_signed={is_signed}"
15451526
)),
15461527
}
15471528
}
@@ -1566,16 +1547,14 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> {
15661547
_ => match self.lookup_type(val.ty) {
15671548
SpirvType::Pointer { pointee } => (val, pointee),
15681549
other => self.fatal(&format!(
1569-
"pointercast called on non-pointer source type: {:?}",
1570-
other
1550+
"pointercast called on non-pointer source type: {other:?}"
15711551
)),
15721552
},
15731553
};
15741554
let dest_pointee = match self.lookup_type(dest_ty) {
15751555
SpirvType::Pointer { pointee } => pointee,
15761556
other => self.fatal(&format!(
1577-
"pointercast called on non-pointer dest type: {:?}",
1578-
other
1557+
"pointercast called on non-pointer dest type: {other:?}"
15791558
)),
15801559
};
15811560
if val.ty == dest_ty {
@@ -1869,8 +1848,7 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> {
18691848
) {
18701849
if flags != MemFlags::empty() {
18711850
self.err(&format!(
1872-
"memcpy with mem flags is not supported yet: {:?}",
1873-
flags
1851+
"memcpy with mem flags is not supported yet: {flags:?}"
18741852
));
18751853
}
18761854
let const_size = self.builder.lookup_const_u64(size);
@@ -1928,8 +1906,7 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> {
19281906
) {
19291907
if flags != MemFlags::empty() {
19301908
self.err(&format!(
1931-
"memset with mem flags is not supported yet: {:?}",
1932-
flags
1909+
"memset with mem flags is not supported yet: {flags:?}"
19331910
));
19341911
}
19351912
let elem_ty = match self.lookup_type(ptr.ty) {
@@ -1979,8 +1956,7 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> {
19791956
let result_type = match self.lookup_type(vec.ty) {
19801957
SpirvType::Vector { element, .. } => element,
19811958
other => self.fatal(&format!(
1982-
"extract_element not implemented on type {:?}",
1983-
other
1959+
"extract_element not implemented on type {other:?}"
19841960
)),
19851961
};
19861962
match self.builder.lookup_const_u64(idx) {
@@ -2046,7 +2022,7 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> {
20462022
SpirvType::Adt { field_types, .. } => {
20472023
assert_ty_eq!(self, field_types[idx as usize], elt.ty);
20482024
}
2049-
other => self.fatal(&format!("insert_value not implemented on type {:?}", other)),
2025+
other => self.fatal(&format!("insert_value not implemented on type {other:?}")),
20502026
};
20512027
self.emit()
20522028
.composite_insert(
@@ -2111,8 +2087,7 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> {
21112087
let dst_pointee_ty = match self.lookup_type(dst.ty) {
21122088
SpirvType::Pointer { pointee } => pointee,
21132089
ty => self.fatal(&format!(
2114-
"atomic_cmpxchg called on variable that wasn't a pointer: {:?}",
2115-
ty
2090+
"atomic_cmpxchg called on variable that wasn't a pointer: {ty:?}"
21162091
)),
21172092
};
21182093
assert_ty_eq!(self, dst_pointee_ty, cmp.ty);
@@ -2148,8 +2123,7 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> {
21482123
let dst_pointee_ty = match self.lookup_type(dst.ty) {
21492124
SpirvType::Pointer { pointee } => pointee,
21502125
ty => self.fatal(&format!(
2151-
"atomic_rmw called on variable that wasn't a pointer: {:?}",
2152-
ty
2126+
"atomic_rmw called on variable that wasn't a pointer: {ty:?}"
21532127
)),
21542128
};
21552129
assert_ty_eq!(self, dst_pointee_ty, src.ty);

0 commit comments

Comments
 (0)