diff --git a/crates/rustc_codegen_spirv-types/src/compile_result.rs b/crates/rustc_codegen_spirv-types/src/compile_result.rs index ba56cdaec0..7a19591532 100644 --- a/crates/rustc_codegen_spirv-types/src/compile_result.rs +++ b/crates/rustc_codegen_spirv-types/src/compile_result.rs @@ -74,7 +74,7 @@ impl<'a> Trie<'a> { let full_child_name = if full_name.is_empty() { (*child_name).to_string() } else { - format!("{}::{}", full_name, child_name) + format!("{full_name}::{child_name}") }; if child.present { assert!(child.children.is_empty()); diff --git a/crates/rustc_codegen_spirv/build.rs b/crates/rustc_codegen_spirv/build.rs index bebfc66733..d0f126b65b 100644 --- a/crates/rustc_codegen_spirv/build.rs +++ b/crates/rustc_codegen_spirv/build.rs @@ -10,9 +10,9 @@ use std::process::{Command, ExitCode}; /// `cargo publish`. We need to figure out a way to do this properly, but let's hardcode it for now :/ //const REQUIRED_RUST_TOOLCHAIN: &str = include_str!("../../rust-toolchain"); const REQUIRED_RUST_TOOLCHAIN: &str = r#"[toolchain] -channel = "nightly-2022-10-29" +channel = "nightly-2022-12-18" components = ["rust-src", "rustc-dev", "llvm-tools-preview"] -# commit_hash = 9565dfeb4e6225177bbe78f18cd48a7982f34401"#; +# commit_hash = 0468a00ae3fd6ef1a6a0f9eaf637d7aa9e604acc"#; fn get_rustc_commit_hash() -> Result> { let rustc = std::env::var("RUSTC").unwrap_or_else(|_| String::from("rustc")); @@ -78,7 +78,7 @@ fn main() -> ExitCode { match check_toolchain_version() { Ok(_) => ExitCode::SUCCESS, Err(e) => { - eprint!("{}", e); + eprint!("{e}"); ExitCode::FAILURE } } diff --git a/crates/rustc_codegen_spirv/src/abi.rs b/crates/rustc_codegen_spirv/src/abi.rs index 3d2dce4bad..f612b21c3b 100644 --- a/crates/rustc_codegen_spirv/src/abi.rs +++ b/crates/rustc_codegen_spirv/src/abi.rs @@ -94,7 +94,7 @@ pub(crate) fn provide(providers: &mut Providers) { // FIXME(eddyb) remove this by deriving `Clone` for `LayoutS` upstream. // FIXME(eddyb) the `S` suffix is a naming antipattern, rename upstream. - fn clone_layout<'a>(layout: &LayoutS<'a>) -> LayoutS<'a> { + fn clone_layout(layout: &LayoutS) -> LayoutS { let LayoutS { ref fields, ref variants, @@ -270,7 +270,7 @@ impl fmt::Display for PointeeTy<'_> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self { PointeeTy::Ty(ty) => write!(f, "{}", ty.ty), - PointeeTy::Fn(ty) => write!(f, "{}", ty), + PointeeTy::Fn(ty) => write!(f, "{ty}"), } } } @@ -577,8 +577,7 @@ fn dig_scalar_pointee<'tcx>( Some(old_pointee) if old_pointee != new_pointee => { cx.tcx.sess.fatal(format!( "dig_scalar_pointee: unsupported Pointer with different \ - pointee types ({:?} vs {:?}) at offset {:?} in {:#?}", - old_pointee, new_pointee, offset, layout + pointee types ({old_pointee:?} vs {new_pointee:?}) at offset {offset:?} in {layout:#?}" )); } _ => pointee = Some(new_pointee), @@ -662,8 +661,8 @@ fn trans_aggregate<'tcx>(cx: &CodegenCx<'tcx>, span: Span, ty: TyAndLayout<'tcx> } // returns (field_offsets, size, align) -pub fn auto_struct_layout<'tcx>( - cx: &CodegenCx<'tcx>, +pub fn auto_struct_layout( + cx: &CodegenCx<'_>, field_types: &[Word], ) -> (Vec, Option, Align) { // FIXME(eddyb) use `AccumulateVec`s just like `rustc` itself does. @@ -860,7 +859,7 @@ fn trans_intrinsic_type<'tcx>( None => Err(cx .tcx .sess - .err(format!("Invalid value for Image const generic: {}", value))), + .err(format!("Invalid value for Image const generic: {value}"))), } } diff --git a/crates/rustc_codegen_spirv/src/attr.rs b/crates/rustc_codegen_spirv/src/attr.rs index 9027c3cd85..7667e20d8c 100644 --- a/crates/rustc_codegen_spirv/src/attr.rs +++ b/crates/rustc_codegen_spirv/src/attr.rs @@ -158,7 +158,7 @@ impl AggregatedSpirvAttributes { }) => { cx.tcx .sess - .delay_span_bug(span, format!("multiple {} attributes", category)); + .delay_span_bug(span, format!("multiple {category} attributes")); } } } @@ -228,7 +228,7 @@ impl AggregatedSpirvAttributes { } // FIXME(eddyb) make this reusable from somewhere in `rustc`. -fn target_from_impl_item<'tcx>(tcx: TyCtxt<'tcx>, impl_item: &hir::ImplItem<'_>) -> Target { +fn target_from_impl_item(tcx: TyCtxt<'_>, impl_item: &hir::ImplItem<'_>) -> Target { match impl_item.kind { hir::ImplItemKind::Const(..) => Target::AssocConst, hir::ImplItemKind::Fn(..) => { @@ -333,7 +333,7 @@ impl CheckSpirvAttrVisitor<'_> { if let Err(msg) = valid { self.tcx.sess.span_err( span, - format!("`{:?}` storage class {}", storage_class, msg), + format!("`{storage_class:?}` storage class {msg}"), ); } } @@ -355,8 +355,7 @@ impl CheckSpirvAttrVisitor<'_> { self.tcx.sess.span_err( span, format!( - "attribute is only valid on a {}, not on a {}", - expected_target, target + "attribute is only valid on a {expected_target}, not on a {target}" ), ); } @@ -370,12 +369,9 @@ impl CheckSpirvAttrVisitor<'_> { .sess .struct_span_err( span, - &format!( - "only one {} attribute is allowed on a {}", - category, target - ), + &format!("only one {category} attribute is allowed on a {target}"), ) - .span_note(prev_span, &format!("previous {} attribute", category)) + .span_note(prev_span, &format!("previous {category} attribute")) .emit(); } }, @@ -461,7 +457,7 @@ impl<'tcx> Visitor<'tcx> for CheckSpirvAttrVisitor<'tcx> { } fn visit_variant(&mut self, variant: &'tcx hir::Variant<'tcx>) { - self.check_spirv_attributes(variant.id, Target::Variant); + self.check_spirv_attributes(variant.hir_id, Target::Variant); intravisit::walk_variant(self, variant); } diff --git a/crates/rustc_codegen_spirv/src/builder/builder_methods.rs b/crates/rustc_codegen_spirv/src/builder/builder_methods.rs index f290878cce..8cc2f67abd 100644 --- a/crates/rustc_codegen_spirv/src/builder/builder_methods.rs +++ b/crates/rustc_codegen_spirv/src/builder/builder_methods.rs @@ -193,8 +193,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { .constant_u64(self.span(), memset_fill_u64(fill_byte)) .def(self), _ => self.fatal(&format!( - "memset on integer width {} not implemented yet", - width + "memset on integer width {width} not implemented yet" )), }, SpirvType::Float(width) => match width { @@ -205,8 +204,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { .constant_f64(self.span(), f64::from_bits(memset_fill_u64(fill_byte))) .def(self), _ => self.fatal(&format!( - "memset on float width {} not implemented yet", - width + "memset on float width {width} not implemented yet" )), }, SpirvType::Adt { .. } => self.fatal("memset on structs not implemented yet"), @@ -253,16 +251,14 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { 32 => memset_dynamic_scalar(self, fill_var, 4, false), 64 => memset_dynamic_scalar(self, fill_var, 8, false), _ => self.fatal(&format!( - "memset on integer width {} not implemented yet", - width + "memset on integer width {width} not implemented yet" )), }, SpirvType::Float(width) => match width { 32 => memset_dynamic_scalar(self, fill_var, 4, true), 64 => memset_dynamic_scalar(self, fill_var, 8, true), _ => self.fatal(&format!( - "memset on float width {} not implemented yet", - width + "memset on float width {width} not implemented yet" )), }, SpirvType::Adt { .. } => self.fatal("memset on structs not implemented yet"), @@ -367,7 +363,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { if !self.builder.has_capability(Capability::VariablePointers) { self.zombie( def, - &format!("{} without OpCapability VariablePointers", inst), + &format!("{inst} without OpCapability VariablePointers"), ); } } @@ -725,8 +721,7 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> { fn construct_8(self_: &Builder<'_, '_>, signed: bool, v: u128) -> Operand { if v > u8::MAX as u128 { self_.fatal(&format!( - "Switches to values above u8::MAX not supported: {:?}", - v + "Switches to values above u8::MAX not supported: {v:?}" )) } else if signed { // 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> { fn construct_16(self_: &Builder<'_, '_>, signed: bool, v: u128) -> Operand { if v > u16::MAX as u128 { self_.fatal(&format!( - "Switches to values above u16::MAX not supported: {:?}", - v + "Switches to values above u16::MAX not supported: {v:?}" )) } else if signed { 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> { fn construct_32(self_: &Builder<'_, '_>, _signed: bool, v: u128) -> Operand { if v > u32::MAX as u128 { self_.fatal(&format!( - "Switches to values above u32::MAX not supported: {:?}", - v + "Switches to values above u32::MAX not supported: {v:?}" )) } else { Operand::LiteralInt32(v as u32) @@ -760,8 +753,7 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> { fn construct_64(self_: &Builder<'_, '_>, _signed: bool, v: u128) -> Operand { if v > u64::MAX as u128 { self_.fatal(&format!( - "Switches to values above u64::MAX not supported: {:?}", - v + "Switches to values above u64::MAX not supported: {v:?}" )) } else { Operand::LiteralInt64(v as u64) @@ -776,8 +768,7 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> { 32 => construct_32, 64 => construct_64, other => self.fatal(&format!( - "switch selector cannot have width {} (only 8, 16, 32, and 64 bits allowed)", - other + "switch selector cannot have width {other} (only 8, 16, 32, and 64 bits allowed)" )), }; (signed, construct_case) @@ -1025,8 +1016,7 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> { pointee } ty => self.fatal(&format!( - "load called on variable that wasn't a pointer: {:?}", - ty + "load called on variable that wasn't a pointer: {ty:?}" )), }; self.emit() @@ -1055,8 +1045,7 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> { pointee } ty => self.fatal(&format!( - "atomic_load called on variable that wasn't a pointer: {:?}", - ty + "atomic_load called on variable that wasn't a pointer: {ty:?}" )), }; // TODO: Default to device scope @@ -1126,27 +1115,25 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> { /// Called for `Rvalue::Repeat` when the elem is neither a ZST nor optimizable using memset. fn write_operand_repeatedly( - mut self, + &mut self, cg_elem: OperandRef<'tcx, Self::Value>, count: u64, dest: PlaceRef<'tcx, Self::Value>, - ) -> Self { + ) { let zero = self.const_usize(0); - let start = dest.project_index(&mut self, zero).llval; + let start = dest.project_index(self, zero).llval; let elem_layout = dest.layout.field(self.cx(), 0); - let elem_ty = elem_layout.spirv_type(self.span(), &self); + let elem_ty = elem_layout.spirv_type(self.span(), self); let align = dest.align.restrict_for_offset(elem_layout.size); for i in 0..count { let current = self.inbounds_gep(elem_ty, start, &[self.const_usize(i)]); cg_elem.val.store( - &mut self, + self, PlaceRef::new_sized_aligned(current, cg_elem.layout, align), ); } - - self } fn range_metadata(&mut self, _load: Self::Value, _range: WrappingRange) { @@ -1161,8 +1148,7 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> { let ptr_elem_ty = match self.lookup_type(ptr.ty) { SpirvType::Pointer { pointee } => pointee, ty => self.fatal(&format!( - "store called on variable that wasn't a pointer: {:?}", - ty + "store called on variable that wasn't a pointer: {ty:?}" )), }; @@ -1193,10 +1179,7 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> { flags: MemFlags, ) -> Self::Value { if flags != MemFlags::empty() { - self.err(&format!( - "store_with_flags is not supported yet: {:?}", - flags - )); + self.err(&format!("store_with_flags is not supported yet: {flags:?}")); } self.store(val, ptr, align) } @@ -1211,8 +1194,7 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> { let ptr_elem_ty = match self.lookup_type(ptr.ty) { SpirvType::Pointer { pointee } => pointee, ty => self.fatal(&format!( - "atomic_store called on variable that wasn't a pointer: {:?}", - ty + "atomic_store called on variable that wasn't a pointer: {ty:?}" )), }; assert_ty_eq!(self, ptr_elem_ty, val.ty); @@ -1250,8 +1232,7 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> { pointee } other => self.fatal(&format!( - "struct_gep not on pointer type: {:?}, index {}", - other, idx + "struct_gep not on pointer type: {other:?}, index {idx}" )), }; let pointee_kind = self.lookup_type(pointee); @@ -1266,8 +1247,7 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> { inner_type } other => self.fatal(&format!( - "struct_gep not on struct, array, or vector type: {:?}, index {}", - other, idx + "struct_gep not on struct, array, or vector type: {other:?}, index {idx}" )), }; let result_type = SpirvType::Pointer { @@ -1412,8 +1392,7 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> { match self.lookup_type(val.ty) { SpirvType::Pointer { .. } => (), other => self.fatal(&format!( - "ptrtoint called on non-pointer source type: {:?}", - other + "ptrtoint called on non-pointer source type: {other:?}" )), } if val.ty == dest_ty { @@ -1433,8 +1412,7 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> { match self.lookup_type(dest_ty) { SpirvType::Pointer { .. } => (), other => self.fatal(&format!( - "inttoptr called on non-pointer dest type: {:?}", - other + "inttoptr called on non-pointer dest type: {other:?}" )), } if val.ty == dest_ty { @@ -1542,8 +1520,7 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> { .with_type(dest_ty) } (val_ty, dest_ty_spv) => self.fatal(&format!( - "TODO: intcast not implemented yet: val={:?} val.ty={:?} dest_ty={:?} is_signed={}", - val, val_ty, dest_ty_spv, is_signed + "TODO: intcast not implemented yet: val={val:?} val.ty={val_ty:?} dest_ty={dest_ty_spv:?} is_signed={is_signed}" )), } } @@ -1568,16 +1545,14 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> { _ => match self.lookup_type(val.ty) { SpirvType::Pointer { pointee } => (val, pointee), other => self.fatal(&format!( - "pointercast called on non-pointer source type: {:?}", - other + "pointercast called on non-pointer source type: {other:?}" )), }, }; let dest_pointee = match self.lookup_type(dest_ty) { SpirvType::Pointer { pointee } => pointee, other => self.fatal(&format!( - "pointercast called on non-pointer dest type: {:?}", - other + "pointercast called on non-pointer dest type: {other:?}" )), }; if val.ty == dest_ty { @@ -1871,8 +1846,7 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> { ) { if flags != MemFlags::empty() { self.err(&format!( - "memcpy with mem flags is not supported yet: {:?}", - flags + "memcpy with mem flags is not supported yet: {flags:?}" )); } let const_size = self.builder.lookup_const_u64(size); @@ -1930,8 +1904,7 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> { ) { if flags != MemFlags::empty() { self.err(&format!( - "memset with mem flags is not supported yet: {:?}", - flags + "memset with mem flags is not supported yet: {flags:?}" )); } let elem_ty = match self.lookup_type(ptr.ty) { @@ -1981,8 +1954,7 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> { let result_type = match self.lookup_type(vec.ty) { SpirvType::Vector { element, .. } => element, other => self.fatal(&format!( - "extract_element not implemented on type {:?}", - other + "extract_element not implemented on type {other:?}" )), }; match self.builder.lookup_const_u64(idx) { @@ -2048,7 +2020,7 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> { SpirvType::Adt { field_types, .. } => { assert_ty_eq!(self, field_types[idx as usize], elt.ty); } - other => self.fatal(&format!("insert_value not implemented on type {:?}", other)), + other => self.fatal(&format!("insert_value not implemented on type {other:?}")), }; self.emit() .composite_insert( @@ -2067,11 +2039,11 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> { } // These are used by everyone except msvc - fn cleanup_landing_pad(&mut self, _ty: Self::Type, _pers_fn: Self::Value) -> Self::Value { + fn cleanup_landing_pad(&mut self, _pers_fn: Self::Value) -> (Self::Value, Self::Value) { todo!() } - fn resume(&mut self, _exn: Self::Value) { + fn resume(&mut self, _exn0: Self::Value, _exn1: Self::Value) { todo!() } @@ -2113,8 +2085,7 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> { let dst_pointee_ty = match self.lookup_type(dst.ty) { SpirvType::Pointer { pointee } => pointee, ty => self.fatal(&format!( - "atomic_cmpxchg called on variable that wasn't a pointer: {:?}", - ty + "atomic_cmpxchg called on variable that wasn't a pointer: {ty:?}" )), }; assert_ty_eq!(self, dst_pointee_ty, cmp.ty); @@ -2150,8 +2121,7 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> { let dst_pointee_ty = match self.lookup_type(dst.ty) { SpirvType::Pointer { pointee } => pointee, ty => self.fatal(&format!( - "atomic_rmw called on variable that wasn't a pointer: {:?}", - ty + "atomic_rmw called on variable that wasn't a pointer: {ty:?}" )), }; assert_ty_eq!(self, dst_pointee_ty, src.ty); diff --git a/crates/rustc_codegen_spirv/src/builder/ext_inst.rs b/crates/rustc_codegen_spirv/src/builder/ext_inst.rs index 5e60a0304a..7648da7466 100644 --- a/crates/rustc_codegen_spirv/src/builder/ext_inst.rs +++ b/crates/rustc_codegen_spirv/src/builder/ext_inst.rs @@ -13,7 +13,7 @@ pub struct ExtInst { } impl ExtInst { - pub fn import_glsl<'a, 'tcx>(&mut self, bx: &Builder<'a, 'tcx>) -> Word { + pub fn import_glsl(&mut self, bx: &Builder<'_, '_>) -> Word { if let Some(id) = self.glsl { id } else { @@ -23,11 +23,7 @@ impl ExtInst { } } - pub fn require_integer_functions_2_intel<'a, 'tcx>( - &mut self, - bx: &Builder<'a, 'tcx>, - to_zombie: Word, - ) { + pub fn require_integer_functions_2_intel(&mut self, bx: &Builder<'_, '_>, to_zombie: Word) { if !self.integer_functions_2_intel { self.integer_functions_2_intel = true; if !bx diff --git a/crates/rustc_codegen_spirv/src/builder/intrinsics.rs b/crates/rustc_codegen_spirv/src/builder/intrinsics.rs index 81f800e458..9e283bc7fe 100644 --- a/crates/rustc_codegen_spirv/src/builder/intrinsics.rs +++ b/crates/rustc_codegen_spirv/src/builder/intrinsics.rs @@ -123,8 +123,7 @@ impl<'a, 'tcx> IntrinsicCallMethods<'tcx> for Builder<'a, 'tcx> { } TyKind::Float(_) => self.fadd(args[0].immediate(), args[1].immediate()), other => self.fatal(&format!( - "Unimplemented saturating_add intrinsic type: {:#?}", - other + "Unimplemented saturating_add intrinsic type: {other:#?}" )), }; // TODO: Implement this @@ -139,8 +138,7 @@ impl<'a, 'tcx> IntrinsicCallMethods<'tcx> for Builder<'a, 'tcx> { } TyKind::Float(_) => self.fsub(args[0].immediate(), args[1].immediate()), other => self.fatal(&format!( - "Unimplemented saturating_sub intrinsic type: {:#?}", - other + "Unimplemented saturating_sub intrinsic type: {other:#?}" )), }; // TODO: Implement this @@ -316,11 +314,11 @@ impl<'a, 'tcx> IntrinsicCallMethods<'tcx> for Builder<'a, 'tcx> { let res3 = self.or(res3, res4); self.or(res1, res3) } - other => self.fatal(&format!("bswap not implemented for int width {}", other)), + other => self.fatal(&format!("bswap not implemented for int width {other}")), } } - _ => self.fatal(&format!("TODO: Unknown intrinsic '{}'", name)), + _ => self.fatal(&format!("TODO: Unknown intrinsic '{name}'")), }; if !fn_abi.ret.is_ignore() { diff --git a/crates/rustc_codegen_spirv/src/builder/mod.rs b/crates/rustc_codegen_spirv/src/builder/mod.rs index 08b5d3e488..16bc8ef489 100644 --- a/crates/rustc_codegen_spirv/src/builder/mod.rs +++ b/crates/rustc_codegen_spirv/src/builder/mod.rs @@ -35,7 +35,7 @@ use rustc_span::source_map::Span; use rustc_target::abi::call::{ArgAbi, FnAbi, PassMode}; use rustc_target::abi::{HasDataLayout, Size, TargetDataLayout}; use rustc_target::spec::{HasTargetSpec, Target}; -use std::ops::Deref; +use std::ops::{Deref, Range}; pub struct Builder<'a, 'tcx> { cx: &'a CodegenCx<'tcx>, @@ -137,8 +137,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { pointee } other_type => self.fatal(&format!( - "GEP first deref not implemented for type {:?}", - other_type + "GEP first deref not implemented for type {other_type:?}" )), }; for index in indices.iter().cloned().skip(1) { @@ -294,6 +293,7 @@ impl<'a, 'tcx> DebugInfoBuilderMethods for Builder<'a, 'tcx> { _direct_offset: Size, // NB: each offset implies a deref (i.e. they're steps in a pointer chain). _indirect_offsets: &[Size], + _fragment: Option>, ) { todo!() } @@ -318,7 +318,7 @@ impl<'a, 'tcx> ArgAbiMethods<'tcx> for Builder<'a, 'tcx> { idx: &mut usize, dst: PlaceRef<'tcx, Self::Value>, ) { - fn next<'a, 'tcx>(bx: &mut Builder<'a, 'tcx>, idx: &mut usize) -> SpirvValue { + fn next(bx: &mut Builder<'_, '_>, idx: &mut usize) -> SpirvValue { let val = bx.function_parameter_values.borrow()[&bx.current_fn.def(bx)][*idx]; *idx += 1; val @@ -446,4 +446,8 @@ impl<'tcx> TypeMembershipMethods<'tcx> for CodegenCx<'tcx> { fn typeid_metadata(&self, _typeid: String) -> Self::Value { todo!() } + + fn set_kcfi_type_metadata(&self, _function: Self::Function, _typeid: u32) { + // ignore + } } diff --git a/crates/rustc_codegen_spirv/src/builder/spirv_asm.rs b/crates/rustc_codegen_spirv/src/builder/spirv_asm.rs index fa17ba9703..f7131faa7c 100644 --- a/crates/rustc_codegen_spirv/src/builder/spirv_asm.rs +++ b/crates/rustc_codegen_spirv/src/builder/spirv_asm.rs @@ -64,10 +64,7 @@ impl<'a, 'tcx> AsmBuilderMethods<'tcx> for Builder<'a, 'tcx> { const SUPPORTED_OPTIONS: InlineAsmOptions = InlineAsmOptions::NORETURN; let unsupported_options = options & !SUPPORTED_OPTIONS; if !unsupported_options.is_empty() { - self.err(&format!( - "asm flags not supported: {:?}", - unsupported_options - )); + self.err(&format!("asm flags not supported: {unsupported_options:?}")); } // vec of lines, and each line is vec of tokens let mut tokens = vec![vec![]]; @@ -103,10 +100,9 @@ impl<'a, 'tcx> AsmBuilderMethods<'tcx> for Builder<'a, 'tcx> { span, } => { if let Some(modifier) = modifier { - self.tcx.sess.span_err( - span, - format!("asm modifiers are not supported: {}", modifier), - ); + self.tcx + .sess + .span_err(span, format!("asm modifiers are not supported: {modifier}")); } let line = tokens.last_mut().unwrap(); let typeof_kind = line.last().and_then(|prev| match prev { @@ -167,14 +163,13 @@ impl<'a, 'tcx> AsmBuilderMethods<'tcx> for Builder<'a, 'tcx> { (false, AsmBlock::Open) => (), (false, AsmBlock::End(terminator)) => { self.err(&format!( - "trailing terminator {:?} requires `options(noreturn)`", - terminator + "trailing terminator {terminator:?} requires `options(noreturn)`" )); } } for (id, num) in id_map { if !defined_ids.contains(&num) { - self.err(&format!("%{} is used but not defined", id)); + self.err(&format!("%{id} is used but not defined")); } } } @@ -237,7 +232,7 @@ impl<'cx, 'tcx> Builder<'cx, 'tcx> { Some('\'') => '\'', Some('"') => '"', Some(escape) => { - self.err(&format!("invalid escape '\\{}'", escape)); + self.err(&format!("invalid escape '\\{escape}'")); return None; } }; @@ -312,12 +307,10 @@ impl<'cx, 'tcx> Builder<'cx, 'tcx> { if storage_class != StorageClass::Generic { self.struct_err("TypePointer in asm! requires `Generic` storage class") .note(&format!( - "`{:?}` storage class was specified", - storage_class + "`{storage_class:?}` storage class was specified" )) .help(&format!( - "the storage class will be inferred automatically (e.g. to `{:?}`)", - storage_class + "the storage class will be inferred automatically (e.g. to `{storage_class:?}`)" )) .emit(); } @@ -377,10 +370,7 @@ impl<'cx, 'tcx> Builder<'cx, 'tcx> { } AsmBlock::End(terminator) => { if op != Op::Label { - self.err(&format!( - "expected OpLabel after terminator {:?}", - terminator - )); + self.err(&format!("expected OpLabel after terminator {terminator:?}")); } AsmBlock::Open @@ -461,7 +451,7 @@ impl<'cx, 'tcx> Builder<'cx, 'tcx> { let inst_class = if let Some(inst) = inst_class { inst } else { - self.err(&format!("unknown spirv instruction {}", inst_name)); + self.err(&format!("unknown spirv instruction {inst_name}")); return; }; let result_id = match out_register { @@ -792,7 +782,7 @@ impl<'cx, 'tcx> Builder<'cx, 'tcx> { _ => { self.tcx .sess - .span_err(span, format!("invalid register: {}", reg)); + .span_err(span, format!("invalid register: {reg}")); } } } @@ -809,7 +799,7 @@ impl<'cx, 'tcx> Builder<'cx, 'tcx> { Some(OutRegister::Regular({ let num = *id_map.entry(id).or_insert_with(|| self.emit().id()); if !defined_ids.insert(num) { - self.err(&format!("%{} is defined more than once", id)); + self.err(&format!("%{id} is defined more than once")); } num })) @@ -1071,7 +1061,7 @@ impl<'cx, 'tcx> Builder<'cx, 'tcx> { (OperandKind::LiteralInteger, Some(word)) => match word.parse() { Ok(v) => inst.operands.push(dr::Operand::LiteralInt32(v)), - Err(e) => self.err(&format!("invalid integer: {}", e)), + Err(e) => self.err(&format!("invalid integer: {e}")), }, (OperandKind::LiteralString, _) => { if let Token::String(value) = token { @@ -1126,7 +1116,7 @@ impl<'cx, 'tcx> Builder<'cx, 'tcx> { } (OperandKind::LiteralExtInstInteger, Some(word)) => match word.parse() { Ok(v) => inst.operands.push(dr::Operand::LiteralExtInstInteger(v)), - Err(e) => self.err(&format!("invalid integer: {}", e)), + Err(e) => self.err(&format!("invalid integer: {e}")), }, (OperandKind::LiteralSpecConstantOpInteger, Some(word)) => { match self.instruction_table.table.get(word) { @@ -1147,25 +1137,22 @@ impl<'cx, 'tcx> Builder<'cx, 'tcx> { Some(Token::Word(word)) => match word.parse() { Ok(v) => inst.operands.push(dr::Operand::LiteralInt32(v)), Err(e) => { - self.err(&format!("invalid integer: {}", e)); + self.err(&format!("invalid integer: {e}")); } }, Some(Token::String(_)) => { - self.err(&format!( - "expected a literal, not a string for a {:?}", - kind - )); + self.err(&format!("expected a literal, not a string for a {kind:?}")); } Some(Token::Placeholder(_, span)) => { self.tcx.sess.span_err( span, - format!("expected a literal, not a dynamic value for a {:?}", kind), + format!("expected a literal, not a dynamic value for a {kind:?}"), ); } Some(Token::Typeof(_, span, _)) => { self.tcx.sess.span_err( span, - format!("expected a literal, not a type for a {:?}", kind), + format!("expected a literal, not a type for a {kind:?}"), ); } None => { @@ -1191,192 +1178,183 @@ impl<'cx, 'tcx> Builder<'cx, 'tcx> { (OperandKind::ImageOperands, Some(word)) => { match parse_bitflags_operand(IMAGE_OPERANDS, word) { Some(x) => inst.operands.push(dr::Operand::ImageOperands(x)), - None => self.err(&format!("Unknown ImageOperands {}", word)), + None => self.err(&format!("Unknown ImageOperands {word}")), } } (OperandKind::FPFastMathMode, Some(word)) => { match parse_bitflags_operand(FP_FAST_MATH_MODE, word) { Some(x) => inst.operands.push(dr::Operand::FPFastMathMode(x)), - None => self.err(&format!("Unknown FPFastMathMode {}", word)), + None => self.err(&format!("Unknown FPFastMathMode {word}")), } } (OperandKind::SelectionControl, Some(word)) => { match parse_bitflags_operand(SELECTION_CONTROL, word) { Some(x) => inst.operands.push(dr::Operand::SelectionControl(x)), - None => self.err(&format!("Unknown SelectionControl {}", word)), + None => self.err(&format!("Unknown SelectionControl {word}")), } } (OperandKind::LoopControl, Some(word)) => { match parse_bitflags_operand(LOOP_CONTROL, word) { Some(x) => inst.operands.push(dr::Operand::LoopControl(x)), - None => self.err(&format!("Unknown LoopControl {}", word)), + None => self.err(&format!("Unknown LoopControl {word}")), } } (OperandKind::FunctionControl, Some(word)) => { match parse_bitflags_operand(FUNCTION_CONTROL, word) { Some(x) => inst.operands.push(dr::Operand::FunctionControl(x)), - None => self.err(&format!("Unknown FunctionControl {}", word)), + None => self.err(&format!("Unknown FunctionControl {word}")), } } (OperandKind::MemorySemantics, Some(word)) => { match parse_bitflags_operand(MEMORY_SEMANTICS, word) { Some(x) => inst.operands.push(dr::Operand::MemorySemantics(x)), - None => self.err(&format!("Unknown MemorySemantics {}", word)), + None => self.err(&format!("Unknown MemorySemantics {word}")), } } (OperandKind::MemoryAccess, Some(word)) => { match parse_bitflags_operand(MEMORY_ACCESS, word) { Some(x) => inst.operands.push(dr::Operand::MemoryAccess(x)), - None => self.err(&format!("Unknown MemoryAccess {}", word)), + None => self.err(&format!("Unknown MemoryAccess {word}")), } } (OperandKind::KernelProfilingInfo, Some(word)) => { match parse_bitflags_operand(KERNEL_PROFILING_INFO, word) { Some(x) => inst.operands.push(dr::Operand::KernelProfilingInfo(x)), - None => self.err(&format!("Unknown KernelProfilingInfo {}", word)), + None => self.err(&format!("Unknown KernelProfilingInfo {word}")), } } (OperandKind::RayFlags, Some(word)) => match parse_bitflags_operand(RAY_FLAGS, word) { Some(x) => inst.operands.push(dr::Operand::RayFlags(x)), - None => self.err(&format!("Unknown RayFlags {}", word)), + None => self.err(&format!("Unknown RayFlags {word}")), }, (OperandKind::FragmentShadingRate, Some(word)) => { match parse_bitflags_operand(FRAGMENT_SHADING_RATE, word) { Some(x) => inst.operands.push(dr::Operand::FragmentShadingRate(x)), - None => self.err(&format!("Unknown FragmentShadingRate {}", word)), + None => self.err(&format!("Unknown FragmentShadingRate {word}")), } } (OperandKind::SourceLanguage, Some(word)) => match word.parse() { Ok(x) => inst.operands.push(dr::Operand::SourceLanguage(x)), - Err(()) => self.err(&format!("Unknown SourceLanguage {}", word)), + Err(()) => self.err(&format!("Unknown SourceLanguage {word}")), }, (OperandKind::ExecutionModel, Some(word)) => match word.parse() { Ok(x) => inst.operands.push(dr::Operand::ExecutionModel(x)), - Err(()) => self.err(&format!("unknown ExecutionModel {}", word)), + Err(()) => self.err(&format!("unknown ExecutionModel {word}")), }, (OperandKind::AddressingModel, Some(word)) => match word.parse() { Ok(x) => inst.operands.push(dr::Operand::AddressingModel(x)), - Err(()) => self.err(&format!("unknown AddressingModel {}", word)), + Err(()) => self.err(&format!("unknown AddressingModel {word}")), }, (OperandKind::MemoryModel, Some(word)) => match word.parse() { Ok(x) => inst.operands.push(dr::Operand::MemoryModel(x)), - Err(()) => self.err(&format!("unknown MemoryModel {}", word)), + Err(()) => self.err(&format!("unknown MemoryModel {word}")), }, (OperandKind::ExecutionMode, Some(word)) => match word.parse() { Ok(x) => inst.operands.push(dr::Operand::ExecutionMode(x)), - Err(()) => self.err(&format!("unknown ExecutionMode {}", word)), + Err(()) => self.err(&format!("unknown ExecutionMode {word}")), }, (OperandKind::StorageClass, Some(word)) => match word.parse() { Ok(x) => inst.operands.push(dr::Operand::StorageClass(x)), - Err(()) => self.err(&format!("unknown StorageClass {}", word)), + Err(()) => self.err(&format!("unknown StorageClass {word}")), }, (OperandKind::Dim, Some(word)) => match word.parse() { Ok(x) => inst.operands.push(dr::Operand::Dim(x)), - Err(()) => self.err(&format!("unknown Dim {}", word)), + Err(()) => self.err(&format!("unknown Dim {word}")), }, (OperandKind::SamplerAddressingMode, Some(word)) => match word.parse() { Ok(x) => inst.operands.push(dr::Operand::SamplerAddressingMode(x)), - Err(()) => self.err(&format!("unknown SamplerAddressingMode {}", word)), + Err(()) => self.err(&format!("unknown SamplerAddressingMode {word}")), }, (OperandKind::SamplerFilterMode, Some(word)) => match word.parse() { Ok(x) => inst.operands.push(dr::Operand::SamplerFilterMode(x)), - Err(()) => self.err(&format!("unknown SamplerFilterMode {}", word)), + Err(()) => self.err(&format!("unknown SamplerFilterMode {word}")), }, (OperandKind::ImageFormat, Some(word)) => match word.parse() { Ok(x) => inst.operands.push(dr::Operand::ImageFormat(x)), - Err(()) => self.err(&format!("unknown ImageFormat {}", word)), + Err(()) => self.err(&format!("unknown ImageFormat {word}")), }, (OperandKind::ImageChannelOrder, Some(word)) => match word.parse() { Ok(x) => inst.operands.push(dr::Operand::ImageChannelOrder(x)), - Err(()) => self.err(&format!("unknown ImageChannelOrder {}", word)), + Err(()) => self.err(&format!("unknown ImageChannelOrder {word}")), }, (OperandKind::ImageChannelDataType, Some(word)) => match word.parse() { Ok(x) => inst.operands.push(dr::Operand::ImageChannelDataType(x)), - Err(()) => self.err(&format!("unknown ImageChannelDataType {}", word)), + Err(()) => self.err(&format!("unknown ImageChannelDataType {word}")), }, (OperandKind::FPRoundingMode, Some(word)) => match word.parse() { Ok(x) => inst.operands.push(dr::Operand::FPRoundingMode(x)), - Err(()) => self.err(&format!("unknown FPRoundingMode {}", word)), + Err(()) => self.err(&format!("unknown FPRoundingMode {word}")), }, (OperandKind::LinkageType, Some(word)) => match word.parse() { Ok(x) => inst.operands.push(dr::Operand::LinkageType(x)), - Err(()) => self.err(&format!("unknown LinkageType {}", word)), + Err(()) => self.err(&format!("unknown LinkageType {word}")), }, (OperandKind::AccessQualifier, Some(word)) => match word.parse() { Ok(x) => inst.operands.push(dr::Operand::AccessQualifier(x)), - Err(()) => self.err(&format!("unknown AccessQualifier {}", word)), + Err(()) => self.err(&format!("unknown AccessQualifier {word}")), }, (OperandKind::FunctionParameterAttribute, Some(word)) => match word.parse() { Ok(x) => inst .operands .push(dr::Operand::FunctionParameterAttribute(x)), - Err(()) => self.err(&format!("unknown FunctionParameterAttribute {}", word)), + Err(()) => self.err(&format!("unknown FunctionParameterAttribute {word}")), }, (OperandKind::Decoration, Some(word)) => match word.parse() { Ok(x) => inst.operands.push(dr::Operand::Decoration(x)), - Err(()) => self.err(&format!("unknown Decoration {}", word)), + Err(()) => self.err(&format!("unknown Decoration {word}")), }, (OperandKind::BuiltIn, Some(word)) => match word.parse() { Ok(x) => inst.operands.push(dr::Operand::BuiltIn(x)), - Err(()) => self.err(&format!("unknown BuiltIn {}", word)), + Err(()) => self.err(&format!("unknown BuiltIn {word}")), }, (OperandKind::Scope, Some(word)) => match word.parse() { Ok(x) => inst.operands.push(dr::Operand::Scope(x)), - Err(()) => self.err(&format!("unknown Scope {}", word)), + Err(()) => self.err(&format!("unknown Scope {word}")), }, (OperandKind::GroupOperation, Some(word)) => match word.parse() { Ok(x) => inst.operands.push(dr::Operand::GroupOperation(x)), - Err(()) => self.err(&format!("unknown GroupOperation {}", word)), + Err(()) => self.err(&format!("unknown GroupOperation {word}")), }, (OperandKind::KernelEnqueueFlags, Some(word)) => match word.parse() { Ok(x) => inst.operands.push(dr::Operand::KernelEnqueueFlags(x)), - Err(()) => self.err(&format!("unknown KernelEnqueueFlags {}", word)), + Err(()) => self.err(&format!("unknown KernelEnqueueFlags {word}")), }, (OperandKind::Capability, Some(word)) => match word.parse() { Ok(x) => inst.operands.push(dr::Operand::Capability(x)), - Err(()) => self.err(&format!("unknown Capability {}", word)), + Err(()) => self.err(&format!("unknown Capability {word}")), }, (OperandKind::RayQueryIntersection, Some(word)) => match word.parse() { Ok(x) => inst.operands.push(dr::Operand::RayQueryIntersection(x)), - Err(()) => self.err(&format!("unknown RayQueryIntersection {}", word)), + Err(()) => self.err(&format!("unknown RayQueryIntersection {word}")), }, (OperandKind::RayQueryCommittedIntersectionType, Some(word)) => match word.parse() { Ok(x) => inst .operands .push(dr::Operand::RayQueryCommittedIntersectionType(x)), - Err(()) => self.err(&format!( - "unknown RayQueryCommittedIntersectionType {}", - word - )), + Err(()) => self.err(&format!("unknown RayQueryCommittedIntersectionType {word}")), }, (OperandKind::RayQueryCandidateIntersectionType, Some(word)) => match word.parse() { Ok(x) => inst .operands .push(dr::Operand::RayQueryCandidateIntersectionType(x)), - Err(()) => self.err(&format!( - "unknown RayQueryCandidateIntersectionType {}", - word - )), + Err(()) => self.err(&format!("unknown RayQueryCandidateIntersectionType {word}")), }, (kind, None) => match token { Token::Word(_) => bug!(), Token::String(_) => { - self.err(&format!( - "expected a literal, not a string for a {:?}", - kind - )); + self.err(&format!("expected a literal, not a string for a {kind:?}")); } Token::Placeholder(_, span) => { self.tcx.sess.span_err( span, - format!("expected a literal, not a dynamic value for a {:?}", kind), + format!("expected a literal, not a dynamic value for a {kind:?}"), ); } Token::Typeof(_, span, _) => { self.tcx.sess.span_err( span, - format!("expected a literal, not a type for a {:?}", kind), + format!("expected a literal, not a type for a {kind:?}"), ); } }, diff --git a/crates/rustc_codegen_spirv/src/builder_spirv.rs b/crates/rustc_codegen_spirv/src/builder_spirv.rs index a3d6a44512..da2b6cec13 100644 --- a/crates/rustc_codegen_spirv/src/builder_spirv.rs +++ b/crates/rustc_codegen_spirv/src/builder_spirv.rs @@ -665,8 +665,7 @@ impl<'tcx> BuilderSpirv<'tcx> { assert_eq!( inst.operands.len(), 1, - "global already has initializer defined: {}", - global + "global already has initializer defined: {global}" ); inst.operands.push(Operand::IdRef(initializer)); module.types_global_values.push(inst); diff --git a/crates/rustc_codegen_spirv/src/codegen_cx/constant.rs b/crates/rustc_codegen_spirv/src/codegen_cx/constant.rs index 915447bb4a..34267e7655 100644 --- a/crates/rustc_codegen_spirv/src/codegen_cx/constant.rs +++ b/crates/rustc_codegen_spirv/src/codegen_cx/constant.rs @@ -66,7 +66,7 @@ impl<'tcx> CodegenCx<'tcx> { _ => self .tcx .sess - .fatal(format!("Invalid constant value for bool: {}", val)), + .fatal(format!("Invalid constant value for bool: {val}")), }, SpirvType::Integer(128, _) => { let result = self.undef(ty); @@ -233,7 +233,7 @@ impl<'tcx> ConstMethods<'tcx> for CodegenCx<'tcx> { _ => self .tcx .sess - .fatal(format!("Invalid constant value for bool: {}", data)), + .fatal(format!("Invalid constant value for bool: {data}")), }, other => self.tcx.sess.fatal(format!( "scalar_to_backend Primitive::Int not supported on type {}", @@ -426,7 +426,7 @@ impl<'tcx> CodegenCx<'tcx> { other => { self.tcx .sess - .fatal(format!("invalid size for integer: {}", other)); + .fatal(format!("invalid size for integer: {other}")); } }; Primitive::Int(integer, int_signedness) @@ -437,7 +437,7 @@ impl<'tcx> CodegenCx<'tcx> { other => { self.tcx .sess - .fatal(format!("invalid size for float: {}", other)); + .fatal(format!("invalid size for float: {other}")); } }, SpirvType::Pointer { .. } => Primitive::Pointer, diff --git a/crates/rustc_codegen_spirv/src/codegen_cx/declare.rs b/crates/rustc_codegen_spirv/src/codegen_cx/declare.rs index b3cb866ca4..6d9fe747ec 100644 --- a/crates/rustc_codegen_spirv/src/codegen_cx/declare.rs +++ b/crates/rustc_codegen_spirv/src/codegen_cx/declare.rs @@ -142,8 +142,7 @@ impl<'tcx> CodegenCx<'tcx> { } None => { self.tcx.sess.err(format!( - "missing libm intrinsic {}, which is {}", - symbol_name, instance + "missing libm intrinsic {symbol_name}, which is {instance}" )); } } @@ -215,8 +214,7 @@ impl<'tcx> PreDefineMethods<'tcx> for CodegenCx<'tcx> { Linkage::Internal => None, other => { self.tcx.sess.err(format!( - "TODO: Linkage type {:?} not supported yet for static var symbol {}", - other, symbol_name + "TODO: Linkage type {other:?} not supported yet for static var symbol {symbol_name}" )); None } @@ -245,8 +243,7 @@ impl<'tcx> PreDefineMethods<'tcx> for CodegenCx<'tcx> { Linkage::Internal => None, other => { self.tcx.sess.err(format!( - "TODO: Linkage type {:?} not supported yet for function symbol {}", - other, symbol_name + "TODO: Linkage type {other:?} not supported yet for function symbol {symbol_name}" )); None } diff --git a/crates/rustc_codegen_spirv/src/codegen_cx/entry.rs b/crates/rustc_codegen_spirv/src/codegen_cx/entry.rs index 4e71932db5..93a720492f 100644 --- a/crates/rustc_codegen_spirv/src/codegen_cx/entry.rs +++ b/crates/rustc_codegen_spirv/src/codegen_cx/entry.rs @@ -38,7 +38,7 @@ impl<'tcx> CodegenCx<'tcx> { } else { self.tcx .sess - .span_err(span, format!("Cannot declare {} as an entry point", name)); + .span_err(span, format!("Cannot declare {name} as an entry point")); return; }; let body = self @@ -253,17 +253,16 @@ impl<'tcx> CodegenCx<'tcx> { .struct_span_err(hir_param.span, "storage class mismatch") .span_label( storage_class_attr.span, - format!("{:?} specified in attribute", storage_class), + format!("{storage_class:?} specified in attribute"), ) .span_label( hir_param.ty_span, - format!("{:?} inferred from type", inferred), + format!("{inferred:?} inferred from type"), ) .span_help( storage_class_attr.span, &format!( - "remove storage class attribute to use {:?} as storage class", - inferred + "remove storage class attribute to use {inferred:?} as storage class" ), ) .emit(); @@ -405,8 +404,7 @@ impl<'tcx> CodegenCx<'tcx> { self.tcx.sess.span_fatal( hir_param.ty_span, format!( - "unsized types are not supported for storage class {:?}", - storage_class + "unsized types are not supported for storage class {storage_class:?}" ), ); } diff --git a/crates/rustc_codegen_spirv/src/codegen_cx/mod.rs b/crates/rustc_codegen_spirv/src/codegen_cx/mod.rs index e9cb0859e2..7cddc6ec62 100644 --- a/crates/rustc_codegen_spirv/src/codegen_cx/mod.rs +++ b/crates/rustc_codegen_spirv/src/codegen_cx/mod.rs @@ -281,7 +281,7 @@ impl CodegenArgs { pub fn from_session(sess: &Session) -> Self { match CodegenArgs::parse(&sess.opts.cg.llvm_args) { Ok(ok) => ok, - Err(err) => sess.fatal(format!("Unable to parse llvm-args: {}", err)), + Err(err) => sess.fatal(format!("Unable to parse llvm-args: {err}")), } } diff --git a/crates/rustc_codegen_spirv/src/codegen_cx/type_.rs b/crates/rustc_codegen_spirv/src/codegen_cx/type_.rs index 8191d694b2..5f8e9be8fe 100644 --- a/crates/rustc_codegen_spirv/src/codegen_cx/type_.rs +++ b/crates/rustc_codegen_spirv/src/codegen_cx/type_.rs @@ -177,6 +177,14 @@ impl<'tcx> BaseTypeMethods<'tcx> for CodegenCx<'tcx> { SpirvType::Float(64).def(DUMMY_SP, self) } + fn type_array(&self, ty: Self::Type, len: u64) -> Self::Type { + SpirvType::Array { + element: ty, + count: self.constant_u64(DUMMY_SP, len), + } + .def(DUMMY_SP, self) + } + fn type_func(&self, args: &[Self::Type], ret: Self::Type) -> Self::Type { SpirvType::Function { return_type: ret, @@ -209,7 +217,7 @@ impl<'tcx> BaseTypeMethods<'tcx> for CodegenCx<'tcx> { other => self .tcx .sess - .fatal(format!("Invalid float width in type_kind: {}", other)), + .fatal(format!("Invalid float width in type_kind: {other}")), }, SpirvType::Adt { .. } | SpirvType::InterfaceBlock { .. } => { TypeKind::Struct @@ -239,8 +247,7 @@ impl<'tcx> BaseTypeMethods<'tcx> for CodegenCx<'tcx> { SpirvType::Pointer { pointee } => pointee, SpirvType::Vector { element, .. } => element, spirv_type => self.tcx.sess.fatal(format!( - "element_type called on invalid type: {:?}", - spirv_type + "element_type called on invalid type: {spirv_type:?}" )), } } @@ -252,7 +259,7 @@ impl<'tcx> BaseTypeMethods<'tcx> for CodegenCx<'tcx> { ty => self .tcx .sess - .fatal(format!("vector_length called on non-vector type: {:?}", ty)), + .fatal(format!("vector_length called on non-vector type: {ty:?}")), } } @@ -262,7 +269,7 @@ impl<'tcx> BaseTypeMethods<'tcx> for CodegenCx<'tcx> { ty => self .tcx .sess - .fatal(format!("float_width called on non-float type: {:?}", ty)), + .fatal(format!("float_width called on non-float type: {ty:?}")), } } @@ -273,7 +280,7 @@ impl<'tcx> BaseTypeMethods<'tcx> for CodegenCx<'tcx> { ty => self .tcx .sess - .fatal(format!("int_width called on non-integer type: {:?}", ty)), + .fatal(format!("int_width called on non-integer type: {ty:?}")), } } diff --git a/crates/rustc_codegen_spirv/src/lib.rs b/crates/rustc_codegen_spirv/src/lib.rs index 0da0bced2a..3abc1b1a78 100644 --- a/crates/rustc_codegen_spirv/src/lib.rs +++ b/crates/rustc_codegen_spirv/src/lib.rs @@ -114,11 +114,7 @@ use std::io::Write; use std::path::Path; use std::sync::Arc; -fn dump_mir<'tcx>( - tcx: TyCtxt<'tcx>, - mono_items: &[(MonoItem<'_>, (Linkage, Visibility))], - path: &Path, -) { +fn dump_mir(tcx: TyCtxt<'_>, mono_items: &[(MonoItem<'_>, (Linkage, Visibility))], path: &Path) { create_dir_all(path.parent().unwrap()).unwrap(); let mut file = File::create(path).unwrap(); for &(mono_item, (_, _)) in mono_items { @@ -384,12 +380,12 @@ impl WriteBackendMethods for SpirvCodegenBackend { } impl ExtraBackendMethods for SpirvCodegenBackend { - fn codegen_allocator<'tcx>( + fn codegen_allocator( &self, - _: TyCtxt<'tcx>, + _: TyCtxt<'_>, _: &str, _: AllocatorKind, - _: bool, + _: AllocatorKind, ) -> Self::Module { todo!() } diff --git a/crates/rustc_codegen_spirv/src/link.rs b/crates/rustc_codegen_spirv/src/link.rs index 998379052f..7e78544305 100644 --- a/crates/rustc_codegen_spirv/src/link.rs +++ b/crates/rustc_codegen_spirv/src/link.rs @@ -18,6 +18,7 @@ use rustc_session::config::{CrateType, DebugInfo, Lto, OptLevel, OutputFilenames use rustc_session::output::{check_file_is_writeable, invalid_output_for_target, out_filename}; use rustc_session::utils::NativeLibKind; use rustc_session::Session; +use rustc_span::Symbol; use std::collections::BTreeMap; use std::ffi::{CString, OsStr}; use std::fs::File; @@ -26,8 +27,8 @@ use std::iter; use std::path::{Path, PathBuf}; use std::sync::Arc; -pub fn link<'a>( - sess: &'a Session, +pub fn link( + sess: &Session, codegen_results: &CodegenResults, outputs: &OutputFilenames, crate_name: &str, @@ -58,7 +59,7 @@ pub fn link<'a>( } if outputs.outputs.should_codegen() { - let out_filename = out_filename(sess, crate_type, outputs, crate_name); + let out_filename = out_filename(sess, crate_type, outputs, Symbol::intern(crate_name)); match crate_type { CrateType::Rlib => { link_rlib(sess, codegen_results, &out_filename); @@ -81,7 +82,7 @@ pub fn link<'a>( ); } other => { - sess.err(format!("CrateType {:?} not supported yet", other)); + sess.err(format!("CrateType {other:?} not supported yet")); } } } @@ -115,8 +116,7 @@ fn link_rlib(sess: &Session, codegen_results: &CodegenResults, out_filename: &Pa } if let Some(name) = lib.name { sess.err(format!( - "Adding native library to rlib not supported yet: {}", - name + "Adding native library to rlib not supported yet: {name}" )); } } @@ -263,12 +263,11 @@ fn post_link_single_module( } else { let reason = match (sess.opts.optimize, sess.opts.debuginfo == DebugInfo::None) { (OptLevel::No, true) => "debuginfo=None".to_string(), - (optlevel, false) => format!("optlevel={:?}", optlevel), - (optlevel, true) => format!("optlevel={:?}, debuginfo=None", optlevel), + (optlevel, false) => format!("optlevel={optlevel:?}"), + (optlevel, true) => format!("optlevel={optlevel:?}, debuginfo=None"), }; sess.warn(format!( - "`spirv-opt` should have ran ({}) but was disabled by `--no-spirv-opt`", - reason + "`spirv-opt` should have ran ({reason}) but was disabled by `--no-spirv-opt`" )); spv_binary } @@ -286,7 +285,7 @@ fn post_link_single_module( { let mut err = sess.struct_err("failed to serialize spirv-binary to disk"); err.note(&format!("module `{}`", out_filename.display())); - err.note(&format!("I/O error: {:#}", e)); + err.note(&format!("I/O error: {e:#}")); err.emit(); } @@ -379,9 +378,9 @@ fn do_spirv_val( } } -fn link_local_crate_native_libs_and_dependent_crate_libs<'a>( +fn link_local_crate_native_libs_and_dependent_crate_libs( rlibs: &mut Vec, - sess: &'a Session, + sess: &Session, crate_type: CrateType, codegen_results: &CodegenResults, ) { @@ -451,12 +450,10 @@ fn add_upstream_native_libraries( } match lib.kind { NativeLibKind::Dylib { .. } | NativeLibKind::Unspecified => sess.fatal(format!( - "TODO: dylib nativelibkind not supported yet: {}", - name + "TODO: dylib nativelibkind not supported yet: {name}" )), NativeLibKind::Framework { .. } => sess.fatal(format!( - "TODO: framework nativelibkind not supported yet: {}", - name + "TODO: framework nativelibkind not supported yet: {name}" )), NativeLibKind::Static { bundle: Some(false), @@ -464,8 +461,7 @@ fn add_upstream_native_libraries( } => { if data[cnum.as_usize() - 1] == Linkage::Static { sess.fatal(format!( - "TODO: staticnobundle nativelibkind not supported yet: {}", - name + "TODO: staticnobundle nativelibkind not supported yet: {name}" )) } } @@ -474,11 +470,10 @@ fn add_upstream_native_libraries( .. } => {} NativeLibKind::RawDylib => { - sess.fatal(format!("raw_dylib feature not yet implemented: {}", name)) + sess.fatal(format!("raw_dylib feature not yet implemented: {name}")) } NativeLibKind::LinkArg => sess.fatal(format!( - "TODO: linkarg nativelibkind not supported yet: {}", - name + "TODO: linkarg nativelibkind not supported yet: {name}" )), } } diff --git a/crates/rustc_codegen_spirv/src/linker/import_export_link.rs b/crates/rustc_codegen_spirv/src/linker/import_export_link.rs index dd6a1b88c9..cf40f72d2c 100644 --- a/crates/rustc_codegen_spirv/src/linker/import_export_link.rs +++ b/crates/rustc_codegen_spirv/src/linker/import_export_link.rs @@ -56,7 +56,7 @@ fn find_import_export_pairs_and_killed_params( }; let type_id = *type_map.get(&id).expect("Unexpected op"); if exports.insert(name, (id, type_id)).is_some() { - return Err(sess.err(format!("Multiple exports found for {:?}", name))); + return Err(sess.err(format!("Multiple exports found for {name:?}"))); } } let mut any_err = None; @@ -68,7 +68,7 @@ fn find_import_export_pairs_and_killed_params( }; let (export_id, export_type) = match exports.get(name) { None => { - any_err = Some(sess.err(format!("Unresolved symbol {:?}", name))); + any_err = Some(sess.err(format!("Unresolved symbol {name:?}"))); continue; } Some(&x) => x, @@ -165,7 +165,7 @@ fn check_tys_equal( Some(def) => { write!(buf, "({}", def.class.opname).unwrap(); if let Some(result_type) = def.result_type { - write!(buf, " {}", result_type).unwrap(); + write!(buf, " {result_type}").unwrap(); } for op in &def.operands { if let Some(id) = op.id_ref_any() { @@ -175,7 +175,7 @@ fn check_tys_equal( } write!(buf, ")").unwrap(); } - None => write!(buf, "{}", ty).unwrap(), + None => write!(buf, "{ty}").unwrap(), } } fn format_ty_(ty_defs: &FxHashMap, ty: Word) -> String { @@ -184,7 +184,7 @@ fn check_tys_equal( result } Err(sess - .struct_err(&format!("Types mismatch for {:?}", name)) + .struct_err(&format!("Types mismatch for {name:?}")) .note(&format!( "import type: {}", format_ty_(&ty_defs, import_type) diff --git a/crates/rustc_codegen_spirv/src/linker/inline.rs b/crates/rustc_codegen_spirv/src/linker/inline.rs index cbf4b7e1f6..33810d41a3 100644 --- a/crates/rustc_codegen_spirv/src/linker/inline.rs +++ b/crates/rustc_codegen_spirv/src/linker/inline.rs @@ -125,8 +125,7 @@ fn deny_recursion_in_module(sess: &Session, module: &Module) -> super::Result<() let current_name = get_name(&names, module.functions[current].def_id().unwrap()); let next_name = get_name(&names, module.functions[next].def_id().unwrap()); *has_recursion = Some(sess.err(format!( - "module has recursion, which is not allowed: `{}` calls `{}`", - current_name, next_name + "module has recursion, which is not allowed: `{current_name}` calls `{next_name}`" ))); break; } diff --git a/crates/rustc_codegen_spirv/src/linker/mod.rs b/crates/rustc_codegen_spirv/src/linker/mod.rs index 826b16f5dc..2e778fd53e 100644 --- a/crates/rustc_codegen_spirv/src/linker/mod.rs +++ b/crates/rustc_codegen_spirv/src/linker/mod.rs @@ -135,7 +135,7 @@ fn get_names(module: &Module) -> FxHashMap { fn get_name<'a>(names: &FxHashMap, id: Word) -> Cow<'a, str> { names.get(&id).map_or_else( - || Cow::Owned(format!("Unnamed function ID %{}", id)), + || Cow::Owned(format!("Unnamed function ID %{id}")), |&s| Cow::Borrowed(s), ) } diff --git a/crates/rustc_codegen_spirv/src/linker/specializer.rs b/crates/rustc_codegen_spirv/src/linker/specializer.rs index 2d8ac5424a..7653e2f585 100644 --- a/crates/rustc_codegen_spirv/src/linker/specializer.rs +++ b/crates/rustc_codegen_spirv/src/linker/specializer.rs @@ -208,7 +208,7 @@ pub fn specialize( replacements.to_concrete(&[], |instance| expander.alloc_instance_id(instance)) { if debug { - eprintln!(" {} -> {:?}", operand, loc); + eprintln!(" {operand} -> {loc:?}"); } func.index_set(loc, operand.into()); } @@ -259,8 +259,8 @@ impl From for Operand { impl fmt::Display for CopyOperand { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self { - Self::IdRef(id) => write!(f, "%{}", id), - Self::StorageClass(s) => write!(f, "{:?}", s), + Self::IdRef(id) => write!(f, "%{id}"), + Self::StorageClass(s) => write!(f, "{s:?}"), } } } @@ -349,12 +349,12 @@ impl Instance { } = self; let generic_args_iter = f(generic_args); FmtBy(move |f| { - write!(f, "%{}<", generic_id)?; + write!(f, "%{generic_id}<")?; for (i, arg) in generic_args_iter.clone().enumerate() { if i != 0 { write!(f, ", ")?; } - write!(f, "{}", arg)?; + write!(f, "{arg}")?; } write!(f, ">") }) @@ -793,18 +793,18 @@ impl InferOperand { FmtBy(move |f| { let var_with_value = |v| { FmtBy(move |f| { - write!(f, "{}", v)?; + write!(f, "{v}")?; match infer_var_value(v) { Value::Unknown => Ok(()), - Value::Known(o) => write!(f, " = {}", o), - Value::SameAs(v) => write!(f, " = {}", v), + Value::Known(o) => write!(f, " = {o}"), + Value::SameAs(v) => write!(f, " = {v}"), } }) }; match self { Self::Unknown => write!(f, "_"), Self::Var(v) => write!(f, "{}", var_with_value(*v)), - Self::Concrete(o) => write!(f, "{}", o), + Self::Concrete(o) => write!(f, "{o}"), Self::Instance(instance) => write!( f, "{}", @@ -1136,7 +1136,7 @@ impl<'a> Match<'a> { let mut found = found.iter().map(display); write!(f, "{}", found.next().unwrap())?; for x in found { - write!(f, " = {}", x)?; + write!(f, " = {x}")?; } Ok(()) }) @@ -1192,8 +1192,8 @@ impl<'a> Match<'a> { _ => None, }; match maybe_idx { - Some(idx) => write!(f, ".{}", idx)?, - None => write!(f, "[{}]", operand)?, + Some(idx) => write!(f, ".{idx}")?, + None => write!(f, "[{operand}]")?, } } write!(f, " = {}", leaf.display_with_infer_cx(cx)) @@ -1503,13 +1503,13 @@ impl InferError { // FIXME(eddyb) better error reporting than this. match self { Self::Conflict(a, b) => { - eprintln!("inference conflict: {:?} vs {:?}", a, b); + eprintln!("inference conflict: {a:?} vs {b:?}"); } } eprint!(" in "); // FIXME(eddyb) deduplicate this with other instruction printing logic. if let Some(result_id) = inst.result_id { - eprint!("%{} = ", result_id); + eprint!("%{result_id} = "); } eprint!("Op{:?}", inst.class.opcode); for operand in inst @@ -1518,7 +1518,7 @@ impl InferError { .iter() .chain(inst.operands.iter()) { - eprint!(" {}", operand); + eprint!(" {operand}"); } eprintln!(); @@ -1950,9 +1950,9 @@ impl<'a, S: Specialization> InferCx<'a, S> { if inst_loc != InstructionLocation::Module { eprint!(" "); } - eprint!("{}", prefix); + eprint!("{prefix}"); if let Some(result_id) = inst.result_id { - eprint!("%{} = ", result_id); + eprint!("%{result_id} = "); } eprint!("Op{:?}", inst.class.opcode); for operand in result_type.into_iter().chain(inputs.iter(cx)) { @@ -2025,9 +2025,9 @@ impl<'a, S: Specialization> InferCx<'a, S> { if self.specializer.debug { eprintln!(); - eprint!("specializer::instantiate_function(%{}", func_id); + eprint!("specializer::instantiate_function(%{func_id}"); if let Some(name) = self.specializer.debug_names.get(&func_id) { - eprint!(" {}", name); + eprint!(" {name}"); } eprintln!("):"); } @@ -2482,7 +2482,7 @@ impl<'a, S: Specialization> Expander<'a, S> { // FIXME(eddyb) maybe dump (transitive) dependencies? could use a def-use graph. for (&generic_id, generic) in &self.specializer.generics { if let Some(name) = self.specializer.debug_names.get(&generic_id) { - writeln!(w, "; {}", name)?; + writeln!(w, "; {name}")?; } write!( @@ -2525,7 +2525,7 @@ impl<'a, S: Specialization> Expander<'a, S> { } else if needed == 1 { write!(w, "{}", params.start)?; } else { - write!(w, "{}", operand)?; + write!(w, "{operand}")?; } } writeln!(w)?; @@ -2536,8 +2536,8 @@ impl<'a, S: Specialization> Expander<'a, S> { let p = Param(i as u32); match v { Value::Unknown => {} - Value::Known(o) => write!(w, " {} = {},", p, o)?, - Value::SameAs(q) => write!(w, " {} = {},", p, q)?, + Value::Known(o) => write!(w, " {p} = {o},")?, + Value::SameAs(q) => write!(w, " {p} = {q},")?, } } writeln!(w)?; diff --git a/crates/rustc_codegen_spirv/src/linker/test.rs b/crates/rustc_codegen_spirv/src/linker/test.rs index 08fe4dcf00..1c760956de 100644 --- a/crates/rustc_codegen_spirv/src/linker/test.rs +++ b/crates/rustc_codegen_spirv/src/linker/test.rs @@ -158,6 +158,7 @@ fn link_with_linker_opts( false, None, false, + false, ); rustc_errors::Handler::with_emitter_and_flags( diff --git a/crates/rustc_codegen_spirv/src/spirv_type.rs b/crates/rustc_codegen_spirv/src/spirv_type.rs index 84f153db4d..5cce80991a 100644 --- a/crates/rustc_codegen_spirv/src/spirv_type.rs +++ b/crates/rustc_codegen_spirv/src/spirv_type.rs @@ -123,7 +123,7 @@ impl SpirvType<'_> { other => cx.zombie_with_span( result, def_span, - &format!("Integer width {} invalid for spir-v", other), + &format!("Integer width {other} invalid for spir-v"), ), }; result @@ -141,7 +141,7 @@ impl SpirvType<'_> { other => cx.zombie_with_span( result, def_span, - &format!("Float width {} invalid for spir-v", other), + &format!("Float width {other} invalid for spir-v"), ), }; result @@ -304,7 +304,7 @@ impl SpirvType<'_> { ref other => cx .tcx .sess - .fatal(format!("def_with_id invalid for type {:?}", other)), + .fatal(format!("def_with_id invalid for type {other:?}")), }; cx.type_cache_def(result, self.tcx_arena_alloc_slices(cx), def_span); result @@ -628,8 +628,8 @@ impl fmt::Display for SpirvTypePrinter<'_, '_> { impl SpirvTypePrinter<'_, '_> { fn display(&self, stack: &mut Vec, f: &mut fmt::Formatter<'_>) -> fmt::Result { - fn ty<'tcx>( - cx: &CodegenCx<'tcx>, + fn ty( + cx: &CodegenCx<'_>, stack: &mut Vec, f: &mut fmt::Formatter<'_>, ty: Word, @@ -648,9 +648,9 @@ impl SpirvTypePrinter<'_, '_> { SpirvType::Bool => f.write_str("bool"), SpirvType::Integer(width, signedness) => { let prefix = if signedness { "i" } else { "u" }; - write!(f, "{}{}", prefix, width) + write!(f, "{prefix}{width}") } - SpirvType::Float(width) => write!(f, "f{}", width), + SpirvType::Float(width) => write!(f, "f{width}"), SpirvType::Adt { def_id: _, align: _, @@ -674,7 +674,7 @@ impl SpirvTypePrinter<'_, '_> { }; if let Some(name) = first_name { - write!(f, " {}", name)?; + write!(f, " {name}")?; } f.write_str(" { ")?; @@ -688,20 +688,20 @@ impl SpirvTypePrinter<'_, '_> { write!(f, "{}: ", field_names[index])?; } ty(self.cx, stack, f, field)?; - write!(f, "{}", suffix)?; + write!(f, "{suffix}")?; } f.write_str(" }") } SpirvType::Vector { element, count } | SpirvType::Matrix { element, count } => { ty(self.cx, stack, f, element)?; - write!(f, "x{}", count) + write!(f, "x{count}") } SpirvType::Array { element, count } => { let len = self.cx.builder.lookup_const_u64(count); let len = len.expect("Array type has invalid count value"); f.write_str("[")?; ty(self.cx, stack, f, element)?; - write!(f, "; {}]", len) + write!(f, "; {len}]") } SpirvType::RuntimeArray { element } => { f.write_str("[")?; @@ -724,7 +724,7 @@ impl SpirvTypePrinter<'_, '_> { ", " }; ty(self.cx, stack, f, arg)?; - write!(f, "{}", suffix)?; + write!(f, "{suffix}")?; } f.write_str(") -> ")?; ty(self.cx, stack, f, return_type) diff --git a/crates/rustc_codegen_spirv/src/symbols.rs b/crates/rustc_codegen_spirv/src/symbols.rs index cb1ff7388e..9d5ea4a460 100644 --- a/crates/rustc_codegen_spirv/src/symbols.rs +++ b/crates/rustc_codegen_spirv/src/symbols.rs @@ -1,7 +1,7 @@ use crate::attr::{Entry, ExecutionModeExtra, IntrinsicType, SpirvAttribute}; use crate::builder::libm_intrinsics; use rspirv::spirv::{BuiltIn, ExecutionMode, ExecutionModel, StorageClass}; -use rustc_ast::ast::{AttrKind, Attribute, Lit, LitIntType, LitKind, NestedMetaItem}; +use rustc_ast::ast::{AttrKind, Attribute, LitIntType, LitKind, MetaItemLit, NestedMetaItem}; use rustc_data_structures::fx::FxHashMap; use rustc_span::symbol::{Ident, Symbol}; use rustc_span::Span; @@ -500,7 +500,7 @@ fn parse_attr_int_value(arg: &NestedMetaItem) -> Result { None => return Err((arg.span(), "attribute must have value".to_string())), }; match arg.name_value_literal() { - Some(&Lit { + Some(&MetaItemLit { kind: LitKind::Int(x, LitIntType::Unsuffixed), .. }) if x <= u32::MAX as u128 => Ok(x as u32), @@ -517,11 +517,11 @@ fn parse_local_size_attr(arg: &NestedMetaItem) -> Result<[u32; 3], ParseAttrErro Some(tuple) if !tuple.is_empty() && tuple.len() < 4 => { let mut local_size = [1; 3]; for (idx, lit) in tuple.iter().enumerate() { - match lit.literal() { - Some(&Lit { + match lit { + NestedMetaItem::Lit(MetaItemLit { kind: LitKind::Int(x, LitIntType::Unsuffixed), .. - }) if x <= u32::MAX as u128 => local_size[idx] = x as u32, + }) if *x <= u32::MAX as u128 => local_size[idx] = *x as u32, _ => return Err((lit.span(), "must be a u32 literal".to_string())), } } diff --git a/crates/rustc_codegen_spirv/src/target_feature.rs b/crates/rustc_codegen_spirv/src/target_feature.rs index f95ce4b3a2..2dee66b90a 100644 --- a/crates/rustc_codegen_spirv/src/target_feature.rs +++ b/crates/rustc_codegen_spirv/src/target_feature.rs @@ -16,7 +16,7 @@ impl std::str::FromStr for TargetFeature { Ok(Self::Extension(Symbol::intern(input))) } else { Ok(Self::Capability(input.parse().map_err(|_err| { - format!("Invalid Capability: `{}`", input) + format!("Invalid Capability: `{input}`") })?)) } } diff --git a/crates/spirv-builder/src/depfile.rs b/crates/spirv-builder/src/depfile.rs index 3911e61ee0..1d36bec17b 100644 --- a/crates/spirv-builder/src/depfile.rs +++ b/crates/spirv-builder/src/depfile.rs @@ -16,7 +16,7 @@ pub fn read_deps_file( f: impl FnMut(RawString, Vec) -> Result<(), Error>, ) -> Result<(), Error> { let file = File::open(file_name) - .map_err(|e| Error::new(e.kind(), format!("Unable to read {:?}: {}", file_name, e)))?; + .map_err(|e| Error::new(e.kind(), format!("Unable to read {file_name:?}: {e}")))?; read_deps_file_from(file, f) } diff --git a/crates/spirv-builder/src/lib.rs b/crates/spirv-builder/src/lib.rs index a13db5994b..5b87eb6d1f 100644 --- a/crates/spirv-builder/src/lib.rs +++ b/crates/spirv-builder/src/lib.rs @@ -312,7 +312,7 @@ impl SpirvBuilder { match self.print_metadata { MetadataPrintout::Full | MetadataPrintout::DependencyOnly => { leaf_deps(&metadata_file, |artifact| { - println!("cargo:rerun-if-changed={}", artifact); + println!("cargo:rerun-if-changed={artifact}"); }) // Close enough .map_err(SpirvBuilderError::MetadataFileMissing)?; @@ -488,8 +488,8 @@ fn invoke_rustc(builder: &SpirvBuilder) -> Result { } let mut target_features = vec![]; - target_features.extend(builder.capabilities.iter().map(|cap| format!("+{:?}", cap))); - target_features.extend(builder.extensions.iter().map(|ext| format!("+ext:{}", ext))); + target_features.extend(builder.capabilities.iter().map(|cap| format!("+{cap:?}"))); + target_features.extend(builder.extensions.iter().map(|ext| format!("+ext:{ext}"))); let target_features = join_checking_for_separators(target_features, ","); if !target_features.is_empty() { rustflags.push(["-Ctarget-feature=", &target_features].concat()); @@ -600,7 +600,7 @@ fn get_sole_artifact(out: &str) -> Option { Some(line) } else { // Pass through invalid lines - println!("{}", line); + println!("{line}"); None } }) diff --git a/crates/spirv-builder/src/watch.rs b/crates/spirv-builder/src/watch.rs index b905da34fa..d38d2410a5 100644 --- a/crates/spirv-builder/src/watch.rs +++ b/crates/spirv-builder/src/watch.rs @@ -38,7 +38,7 @@ impl SpirvBuilder { let _ = tx.try_send(()); } }, - Err(e) => println!("notify error: {:?}", e), + Err(e) => println!("notify error: {e:?}"), }) .expect("Could create watcher"); // This is likely to notice changes in the `target` dir, however, given that `cargo watch` doesn't seem to handle that, @@ -71,7 +71,7 @@ impl SpirvBuilder { let _ = tx.try_send(()); } }, - Err(e) => println!("notify error: {:?}", e), + Err(e) => println!("notify error: {e:?}"), }) .expect("Could create watcher"); leaf_deps(&metadata_file, |it| { diff --git a/crates/spirv-std/macros/src/lib.rs b/crates/spirv-std/macros/src/lib.rs index 61b652670e..07625ab1c4 100644 --- a/crates/spirv-std/macros/src/lib.rs +++ b/crates/spirv-std/macros/src/lib.rs @@ -483,7 +483,7 @@ fn debug_printf_inner(input: DebugPrintfInput) -> TokenStream { let mut has_precision = false; - while matches!(ch, '0'..='9') { + while ch.is_ascii_digit() { ch = match chars.next() { Some(ch) => ch, None => { @@ -508,7 +508,7 @@ fn debug_printf_inner(input: DebugPrintfInput) -> TokenStream { } }; - while matches!(ch, '0'..='9') { + while ch.is_ascii_digit() { ch = match chars.next() { Some(ch) => ch, None => return parsing_error( @@ -525,7 +525,7 @@ fn debug_printf_inner(input: DebugPrintfInput) -> TokenStream { Some('3') => 3, Some('4') => 4, Some(ch) => { - return parsing_error(&format!("Invalid width for vector: {}", ch), span) + return parsing_error(&format!("Invalid width for vector: {ch}"), span) } None => return parsing_error("Missing vector dimensions specifier", span), }; @@ -539,7 +539,7 @@ fn debug_printf_inner(input: DebugPrintfInput) -> TokenStream { Some(ty) => ty, _ => { return parsing_error( - &format!("Unrecognised vector type specifier: '{}'", ch), + &format!("Unrecognised vector type specifier: '{ch}'"), span, ) } @@ -551,7 +551,7 @@ fn debug_printf_inner(input: DebugPrintfInput) -> TokenStream { Some(ty) => ty, _ => { return parsing_error( - &format!("Unrecognised format specifier: '{}'", ch), + &format!("Unrecognised format specifier: '{ch}'"), span, ) } @@ -583,7 +583,7 @@ fn debug_printf_inner(input: DebugPrintfInput) -> TokenStream { { let ident = quote::format_ident!("_{}", i); - let _ = write!(variable_idents, "%{} ", ident); + let _ = write!(variable_idents, "%{ident} "); let assert_fn = match format_argument { FormatType::Scalar { ty } => { @@ -598,7 +598,7 @@ fn debug_printf_inner(input: DebugPrintfInput) -> TokenStream { #ident = in(reg) &#assert_fn(#variable), }); - let op_load = format!("%{ident} = OpLoad _ {{{ident}}}", ident = ident); + let op_load = format!("%{ident} = OpLoad _ {{{ident}}}"); op_loads.push(quote::quote! { #op_load, @@ -610,7 +610,7 @@ fn debug_printf_inner(input: DebugPrintfInput) -> TokenStream { .collect::(); let op_loads = op_loads.into_iter().collect::(); - let op_string = format!("%string = OpString {:?}", format_string); + let op_string = format!("%string = OpString {format_string:?}"); let output = quote::quote! { ::core::arch::asm!( diff --git a/examples/multibuilder/src/main.rs b/examples/multibuilder/src/main.rs index 525d28ff7b..e694b72ee3 100644 --- a/examples/multibuilder/src/main.rs +++ b/examples/multibuilder/src/main.rs @@ -9,5 +9,5 @@ fn main() { .multimodule(true) .build() .unwrap(); - println!("{:#?}", result); + println!("{result:#?}"); } diff --git a/examples/runners/ash/build.rs b/examples/runners/ash/build.rs index 7bf0734bed..5aa3309e79 100644 --- a/examples/runners/ash/build.rs +++ b/examples/runners/ash/build.rs @@ -4,5 +4,5 @@ fn main() { // While OUT_DIR is set for both build.rs and compiling the crate, PROFILE is only set in // build.rs. So, export it to crate compilation as well. let profile = env::var("PROFILE").unwrap(); - println!("cargo:rustc-env=PROFILE={}", profile); + println!("cargo:rustc-env=PROFILE={profile}"); } diff --git a/examples/runners/wgpu/build.rs b/examples/runners/wgpu/build.rs index 52983c1048..4c79f896f8 100644 --- a/examples/runners/wgpu/build.rs +++ b/examples/runners/wgpu/build.rs @@ -11,7 +11,7 @@ fn main() -> Result<(), Box> { // While OUT_DIR is set for both build.rs and compiling the crate, PROFILE is only set in // build.rs. So, export it to crate compilation as well. let profile = env::var("PROFILE").unwrap(); - println!("cargo:rustc-env=PROFILE={}", profile); + println!("cargo:rustc-env=PROFILE={profile}"); if target_os != "android" && target_arch != "wasm32" { return Ok(()); } diff --git a/examples/runners/wgpu/src/compute.rs b/examples/runners/wgpu/src/compute.rs index 07681d4e74..7a896a0005 100644 --- a/examples/runners/wgpu/src/compute.rs +++ b/examples/runners/wgpu/src/compute.rs @@ -173,12 +173,12 @@ pub async fn start_internal( let mut max = 0; for (src, out) in src_range.zip(result.iter().copied()) { if out == u32::MAX { - println!("{}: overflowed", src); + println!("{src}: overflowed"); break; } else if out > max { max = out; // Should produce - println!("{}: {}", src, out); + println!("{src}: {out}"); } } println!( diff --git a/examples/runners/wgpu/src/graphics.rs b/examples/runners/wgpu/src/graphics.rs index 1a8ee5c67f..2a090fc2df 100644 --- a/examples/runners/wgpu/src/graphics.rs +++ b/examples/runners/wgpu/src/graphics.rs @@ -158,7 +158,7 @@ async fn run( let output = match surface.get_current_texture() { Ok(surface) => surface, Err(err) => { - eprintln!("get_current_texture error: {:?}", err); + eprintln!("get_current_texture error: {err:?}"); match err { wgpu::SurfaceError::Lost => { surface.configure(&device, &surface_config); diff --git a/examples/shaders/compute-shader/src/main.rs b/examples/shaders/compute-shader/src/main.rs index ddabff5345..104cf9a26f 100644 --- a/examples/shaders/compute-shader/src/main.rs +++ b/examples/shaders/compute-shader/src/main.rs @@ -19,14 +19,14 @@ fn main() { Some(out) if out > max => { max = out; // Should produce - println!("{}: {}", src, out); + println!("{src}: {out}"); } Some(_) => (), None => { - println!("{}: overflowed", src); + println!("{src}: overflowed"); break; } } } - println!("Took: {:?}", took); + println!("Took: {took:?}"); } diff --git a/rust-toolchain b/rust-toolchain index b20167d23b..930a1f1677 100644 --- a/rust-toolchain +++ b/rust-toolchain @@ -5,9 +5,9 @@ # to the user in the error, instead of "error: invalid channel name '[toolchain]'". [toolchain] -channel = "nightly-2022-10-29" +channel = "nightly-2022-12-18" components = ["rust-src", "rustc-dev", "llvm-tools-preview"] -# commit_hash = 9565dfeb4e6225177bbe78f18cd48a7982f34401 +# commit_hash = 0468a00ae3fd6ef1a6a0f9eaf637d7aa9e604acc # Whenever changing the nightly channel, update the commit hash above, and make # sure to change REQUIRED_TOOLCHAIN in crates/rustc_codegen_spirv/src/build.rs also. diff --git a/tests/src/main.rs b/tests/src/main.rs index d0a30ce23e..4bda1ae715 100644 --- a/tests/src/main.rs +++ b/tests/src/main.rs @@ -50,7 +50,7 @@ impl DepKind { fn target_dir_suffix(self, target: &str) -> String { match self { - Self::SpirvLib => format!("{}/debug/deps", target), + Self::SpirvLib => format!("{target}/debug/deps"), Self::ProcMacro => "debug/deps".into(), } } @@ -136,7 +136,7 @@ impl Runner { // which offer `// only-S` and `// ignore-S` for any stage ID `S`. let stage_id = if spirt { "spirt" } else { "not_spirt" }; - let target = format!("{}{}", TARGET_PREFIX, env); + let target = format!("{TARGET_PREFIX}{env}"); let libs = build_deps(&self.deps_target_dir, &self.codegen_backend_path, &target); let mut flags = test_rustc_flags( &self.codegen_backend_path, @@ -188,7 +188,7 @@ fn build_deps(deps_target_dir: &Path, codegen_backend_path: &Path, target: &str) "compiletests-deps-helper", "-Zbuild-std=core", "-Zbuild-std-features=compiler-builtins-mem", - &*format!("--target={}", target), + &*format!("--target={target}"), ]) .arg("--target-dir") .arg(deps_target_dir) diff --git a/tests/ui/dis/ptr_copy.normal.stderr b/tests/ui/dis/ptr_copy.normal.stderr index d3f5f03c2d..89487413e7 100644 --- a/tests/ui/dis/ptr_copy.normal.stderr +++ b/tests/ui/dis/ptr_copy.normal.stderr @@ -1,7 +1,7 @@ error: Cannot memcpy dynamically sized data - --> $CORE_SRC/intrinsics.rs:2449:9 + --> $CORE_SRC/intrinsics.rs:2519:9 | -2449 | copy(src, dst, count) +2519 | copy(src, dst, count) | ^^^^^^^^^^^^^^^^^^^^^ | = note: Stack: diff --git a/tests/ui/dis/ptr_read.stderr b/tests/ui/dis/ptr_read.stderr index 52ea32090f..20cc4ad01d 100644 --- a/tests/ui/dis/ptr_read.stderr +++ b/tests/ui/dis/ptr_read.stderr @@ -2,7 +2,7 @@ %4 = OpFunctionParameter %5 %6 = OpFunctionParameter %5 %7 = OpLabel -OpLine %8 1139 8 +OpLine %8 1135 8 %9 = OpLoad %10 %4 OpLine %11 9 13 OpStore %6 %9 diff --git a/tests/ui/dis/ptr_read_method.stderr b/tests/ui/dis/ptr_read_method.stderr index 52ea32090f..20cc4ad01d 100644 --- a/tests/ui/dis/ptr_read_method.stderr +++ b/tests/ui/dis/ptr_read_method.stderr @@ -2,7 +2,7 @@ %4 = OpFunctionParameter %5 %6 = OpFunctionParameter %5 %7 = OpLabel -OpLine %8 1139 8 +OpLine %8 1135 8 %9 = OpLoad %10 %4 OpLine %11 9 13 OpStore %6 %9 diff --git a/tests/ui/dis/ptr_write.stderr b/tests/ui/dis/ptr_write.stderr index 332eab0871..fea253a81a 100644 --- a/tests/ui/dis/ptr_write.stderr +++ b/tests/ui/dis/ptr_write.stderr @@ -4,7 +4,7 @@ %7 = OpLabel OpLine %8 9 35 %9 = OpLoad %10 %4 -OpLine %11 1336 8 +OpLine %11 1332 8 OpStore %6 %9 OpNoLine OpReturn diff --git a/tests/ui/dis/ptr_write_method.stderr b/tests/ui/dis/ptr_write_method.stderr index b14f037688..e42322c5b6 100644 --- a/tests/ui/dis/ptr_write_method.stderr +++ b/tests/ui/dis/ptr_write_method.stderr @@ -4,7 +4,7 @@ %7 = OpLabel OpLine %8 9 37 %9 = OpLoad %10 %4 -OpLine %11 1336 8 +OpLine %11 1332 8 OpStore %6 %9 OpNoLine OpReturn diff --git a/tests/ui/image/format.rs b/tests/ui/image/format.rs index 813d09e951..5b4232b172 100644 --- a/tests/ui/image/format.rs +++ b/tests/ui/image/format.rs @@ -5,7 +5,7 @@ use spirv_std::{arch, Image}; #[spirv(fragment)] pub fn main( - #[spirv(descriptor_set = 0, binding = 0)] image: &Image!(2D, format=rgba32f, sampled), + #[spirv(descriptor_set = 0, binding = 0)] image: &Image!(2D, format = rgba32f, sampled), output: &mut glam::Vec4, ) { let texel = image.fetch(glam::IVec2::new(0, 1)); diff --git a/tests/ui/image/gather_err.stderr b/tests/ui/image/gather_err.stderr index 9771aaf049..bede583318 100644 --- a/tests/ui/image/gather_err.stderr +++ b/tests/ui/image/gather_err.stderr @@ -1,10 +1,8 @@ error[E0277]: the trait bound `Image: HasGather` is not satisfied - --> $DIR/gather_err.rs:15:26 + --> $DIR/gather_err.rs:15:34 | 15 | let r1: glam::Vec4 = image1d.gather(*sampler, 0.0f32, 0); - | ^^^^^^^ ------ required by a bound introduced by this call - | | - | the trait `HasGather` is not implemented for `Image` + | ^^^^^^ the trait `HasGather` is not implemented for `Image` | = help: the following other types implement trait `HasGather`: Image @@ -17,12 +15,10 @@ note: required by a bound in `Image::::gather` error[E0277]: the trait bound `Image: HasGather` is not satisfied - --> $DIR/gather_err.rs:16:26 + --> $DIR/gather_err.rs:16:34 | 16 | let r2: glam::Vec4 = image3d.gather(*sampler, v3, 0); - | ^^^^^^^ ------ required by a bound introduced by this call - | | - | the trait `HasGather` is not implemented for `Image` + | ^^^^^^ the trait `HasGather` is not implemented for `Image` | = help: the following other types implement trait `HasGather`: Image diff --git a/tests/ui/image/query/query_levels_err.stderr b/tests/ui/image/query/query_levels_err.stderr index 8273721641..74bbe1645c 100644 --- a/tests/ui/image/query/query_levels_err.stderr +++ b/tests/ui/image/query/query_levels_err.stderr @@ -1,10 +1,8 @@ error[E0277]: the trait bound `Image: HasQueryLevels` is not satisfied - --> $DIR/query_levels_err.rs:12:15 + --> $DIR/query_levels_err.rs:12:21 | 12 | *output = image.query_levels(); - | ^^^^^ ------------ required by a bound introduced by this call - | | - | the trait `HasQueryLevels` is not implemented for `Image` + | ^^^^^^^^^^^^ the trait `HasQueryLevels` is not implemented for `Image` | = help: the following other types implement trait `HasQueryLevels`: Image diff --git a/tests/ui/image/query/query_lod_err.stderr b/tests/ui/image/query/query_lod_err.stderr index b2d4553f61..f969efa95a 100644 --- a/tests/ui/image/query/query_lod_err.stderr +++ b/tests/ui/image/query/query_lod_err.stderr @@ -1,10 +1,8 @@ error[E0277]: the trait bound `Image: HasQueryLevels` is not satisfied - --> $DIR/query_lod_err.rs:13:15 + --> $DIR/query_lod_err.rs:13:21 | 13 | *output = image.query_lod(*sampler, glam::Vec2::new(0.0, 1.0)); - | ^^^^^ --------- required by a bound introduced by this call - | | - | the trait `HasQueryLevels` is not implemented for `Image` + | ^^^^^^^^^ the trait `HasQueryLevels` is not implemented for `Image` | = help: the following other types implement trait `HasQueryLevels`: Image diff --git a/tests/ui/image/query/query_size_err.stderr b/tests/ui/image/query/query_size_err.stderr index c66d6e32f6..b113619b49 100644 --- a/tests/ui/image/query/query_size_err.stderr +++ b/tests/ui/image/query/query_size_err.stderr @@ -1,10 +1,8 @@ error[E0277]: the trait bound `Image: HasQuerySize` is not satisfied - --> $DIR/query_size_err.rs:12:15 + --> $DIR/query_size_err.rs:12:21 | 12 | *output = image.query_size(); - | ^^^^^ ---------- required by a bound introduced by this call - | | - | the trait `HasQuerySize` is not implemented for `Image` + | ^^^^^^^^^^ the trait `HasQuerySize` is not implemented for `Image` | = help: the following other types implement trait `HasQuerySize`: Image diff --git a/tests/ui/image/query/query_size_lod_err.stderr b/tests/ui/image/query/query_size_lod_err.stderr index 94af055d93..1435cdcedf 100644 --- a/tests/ui/image/query/query_size_lod_err.stderr +++ b/tests/ui/image/query/query_size_lod_err.stderr @@ -1,10 +1,8 @@ error[E0277]: the trait bound `Image: HasQuerySizeLod` is not satisfied - --> $DIR/query_size_lod_err.rs:12:15 + --> $DIR/query_size_lod_err.rs:12:21 | 12 | *output = image.query_size_lod(0); - | ^^^^^ -------------- required by a bound introduced by this call - | | - | the trait `HasQuerySizeLod` is not implemented for `Image` + | ^^^^^^^^^^^^^^ the trait `HasQuerySizeLod` is not implemented for `Image` | = help: the following other types implement trait `HasQuerySizeLod`: Image