diff --git a/benches/benches/root.rs b/benches/benches/root.rs index 064617783..630ea6027 100644 --- a/benches/benches/root.rs +++ b/benches/benches/root.rs @@ -39,7 +39,7 @@ impl DeviceState { let adapter_info = adapter.get_info(); - eprintln!("{:?}", adapter_info); + eprintln!("{adapter_info:?}"); let (device, queue) = block_on(adapter.request_device( &wgpu::DeviceDescriptor { diff --git a/benches/benches/shader.rs b/benches/benches/shader.rs index c6aa631d9..f1a949412 100644 --- a/benches/benches/shader.rs +++ b/benches/benches/shader.rs @@ -40,7 +40,7 @@ impl Inputs { _ => continue, }, Err(e) => { - eprintln!("Skipping file: {:?}", e); + eprintln!("Skipping file: {e:?}"); continue; } } diff --git a/examples/src/main.rs b/examples/src/main.rs index 8b149d5a2..5d29d484b 100644 --- a/examples/src/main.rs +++ b/examples/src/main.rs @@ -201,7 +201,7 @@ fn print_unknown_example(_result: Option) {} #[cfg(not(target_arch = "wasm32"))] fn print_unknown_example(result: Option) { if let Some(example) = result { - println!("Unknown example: {}", example); + println!("Unknown example: {example}"); } else { println!("Please specify an example as the first argument!"); } diff --git a/examples/src/timestamp_queries/mod.rs b/examples/src/timestamp_queries/mod.rs index 2921ae4c8..a253938a3 100644 --- a/examples/src/timestamp_queries/mod.rs +++ b/examples/src/timestamp_queries/mod.rs @@ -227,7 +227,7 @@ async fn run() { let queries = submit_render_and_compute_pass_with_queries(&device, &queue); let raw_results = queries.wait_for_results(&device); - println!("Raw timestamp buffer contents: {:?}", raw_results); + println!("Raw timestamp buffer contents: {raw_results:?}"); QueryResults::from_raw_results(raw_results, timestamps_inside_passes).print(&queue); } diff --git a/naga-cli/src/bin/naga.rs b/naga-cli/src/bin/naga.rs index e28519cb0..8cec1801c 100644 --- a/naga-cli/src/bin/naga.rs +++ b/naga-cli/src/bin/naga.rs @@ -853,7 +853,7 @@ fn bulk_validate(args: Args, params: &Parameters) -> anyhow::Result<()> { Ok(parsed) => parsed, Err(error) => { invalid.push(input_path.clone()); - eprintln!("Error validating {}:", input_path); + eprintln!("Error validating {input_path}:"); eprintln!("{error}"); continue; } @@ -866,7 +866,7 @@ fn bulk_validate(args: Args, params: &Parameters) -> anyhow::Result<()> { if let Err(error) = validator.validate(&module) { invalid.push(input_path.clone()); - eprintln!("Error validating {}:", input_path); + eprintln!("Error validating {input_path}:"); if let Some(input) = &input_text { let filename = path.file_name().and_then(std::ffi::OsStr::to_str); emit_annotated_error(&error, filename.unwrap_or("input"), input); diff --git a/naga/src/back/dot/mod.rs b/naga/src/back/dot/mod.rs index 4f29ab776..278087965 100644 --- a/naga/src/back/dot/mod.rs +++ b/naga/src/back/dot/mod.rs @@ -698,7 +698,7 @@ fn write_function_expressions( E::RayQueryGetIntersection { query, committed } => { edges.insert("", query); let ty = if committed { "Committed" } else { "Candidate" }; - (format!("rayQueryGet{}Intersection", ty).into(), 4) + (format!("rayQueryGet{ty}Intersection").into(), 4) } E::SubgroupBallotResult => ("SubgroupBallotResult".into(), 4), E::SubgroupOperationResult { .. } => ("SubgroupOperationResult".into(), 4), diff --git a/naga/src/back/glsl/mod.rs b/naga/src/back/glsl/mod.rs index 159d9cdcf..2ce9f22f2 100644 --- a/naga/src/back/glsl/mod.rs +++ b/naga/src/back/glsl/mod.rs @@ -2645,15 +2645,15 @@ impl<'a, W: Write> Writer<'a, W> { match literal { // Floats are written using `Debug` instead of `Display` because it always appends the // decimal part even it's zero which is needed for a valid glsl float constant - crate::Literal::F64(value) => write!(self.out, "{:?}LF", value)?, - crate::Literal::F32(value) => write!(self.out, "{:?}", value)?, + crate::Literal::F64(value) => write!(self.out, "{value:?}LF")?, + crate::Literal::F32(value) => write!(self.out, "{value:?}")?, // Unsigned integers need a `u` at the end // // While `core` doesn't necessarily need it, it's allowed and since `es` needs it we // always write it as the extra branch wouldn't have any benefit in readability - crate::Literal::U32(value) => write!(self.out, "{}u", value)?, - crate::Literal::I32(value) => write!(self.out, "{}", value)?, - crate::Literal::Bool(value) => write!(self.out, "{}", value)?, + crate::Literal::U32(value) => write!(self.out, "{value}u")?, + crate::Literal::I32(value) => write!(self.out, "{value}")?, + crate::Literal::Bool(value) => write!(self.out, "{value}")?, crate::Literal::I64(_) => { return Err(Error::Custom("GLSL has no 64-bit integer type".into())); } @@ -4614,7 +4614,7 @@ impl<'a, W: Write> Writer<'a, W> { for i in 0..count.get() { // Add the array accessor and recurse. - segments.push(format!("[{}]", i)); + segments.push(format!("[{i}]")); self.collect_push_constant_items(base, segments, layouter, offset, items); segments.pop(); } diff --git a/naga/src/back/hlsl/help.rs b/naga/src/back/hlsl/help.rs index 80f385d01..9032d22c8 100644 --- a/naga/src/back/hlsl/help.rs +++ b/naga/src/back/hlsl/help.rs @@ -1046,8 +1046,7 @@ impl<'a, W: Write> super::Writer<'a, W> { } ref other => { return Err(super::Error::Unimplemented(format!( - "Array length of base {:?}", - other + "Array length of base {other:?}" ))) } }; diff --git a/naga/src/back/hlsl/storage.rs b/naga/src/back/hlsl/storage.rs index 4d3a6af56..9fbdf6769 100644 --- a/naga/src/back/hlsl/storage.rs +++ b/naga/src/back/hlsl/storage.rs @@ -350,7 +350,7 @@ impl super::Writer<'_, W> { self.write_store_value(module, &value, func_ctx)?; writeln!(self.out, "));")?; } else { - write!(self.out, "{}{}.Store(", level, var_name)?; + write!(self.out, "{level}{var_name}.Store(")?; self.write_storage_address(module, &chain, func_ctx)?; write!(self.out, ", ")?; self.write_store_value(module, &value, func_ctx)?; diff --git a/naga/src/back/hlsl/writer.rs b/naga/src/back/hlsl/writer.rs index e33fc79f2..0eb18f0e1 100644 --- a/naga/src/back/hlsl/writer.rs +++ b/naga/src/back/hlsl/writer.rs @@ -965,7 +965,7 @@ impl<'a, W: fmt::Write> super::Writer<'a, W> { let constant = &module.constants[handle]; self.write_type(module, constant.ty)?; let name = &self.names[&NameKey::Constant(handle)]; - write!(self.out, " {}", name)?; + write!(self.out, " {name}")?; // Write size for array type if let TypeInner::Array { base, size, .. } = module.types[constant.ty].inner { self.write_array_size(module, base, size)?; @@ -2383,11 +2383,11 @@ impl<'a, W: fmt::Write> super::Writer<'a, W> { // decimal part even it's zero crate::Literal::F64(value) => write!(self.out, "{value:?}L")?, crate::Literal::F32(value) => write!(self.out, "{value:?}")?, - crate::Literal::U32(value) => write!(self.out, "{}u", value)?, - crate::Literal::I32(value) => write!(self.out, "{}", value)?, - crate::Literal::U64(value) => write!(self.out, "{}uL", value)?, - crate::Literal::I64(value) => write!(self.out, "{}L", value)?, - crate::Literal::Bool(value) => write!(self.out, "{}", value)?, + crate::Literal::U32(value) => write!(self.out, "{value}u")?, + crate::Literal::I32(value) => write!(self.out, "{value}")?, + crate::Literal::U64(value) => write!(self.out, "{value}uL")?, + crate::Literal::I64(value) => write!(self.out, "{value}L")?, + crate::Literal::Bool(value) => write!(self.out, "{value}")?, crate::Literal::AbstractInt(_) | crate::Literal::AbstractFloat(_) => { return Err(Error::Custom( "Abstract types should not appear in IR presented to backends".into(), diff --git a/naga/src/back/msl/mod.rs b/naga/src/back/msl/mod.rs index 96dd142a5..4bc06469e 100644 --- a/naga/src/back/msl/mod.rs +++ b/naga/src/back/msl/mod.rs @@ -437,8 +437,7 @@ impl Options { }) } LocationMode::Uniform => Err(Error::GenericValidation(format!( - "Unexpected Binding::Location({}) for the Uniform mode", - location + "Unexpected Binding::Location({location}) for the Uniform mode" ))), }, } diff --git a/naga/src/back/msl/writer.rs b/naga/src/back/msl/writer.rs index e09ca557a..7ab97f491 100644 --- a/naga/src/back/msl/writer.rs +++ b/naga/src/back/msl/writer.rs @@ -3820,12 +3820,11 @@ impl Writer { writeln!(self.out)?; writeln!( self.out, - "{} {defined_func_name}({arg_type_name} arg) {{ + "{struct_name} {defined_func_name}({arg_type_name} arg) {{ {other_type_name} other; {arg_type_name} fract = {NAMESPACE}::{called_func_name}(arg, other); - return {}{{ fract, other }}; -}}", - struct_name, struct_name + return {struct_name}{{ fract, other }}; +}}" )?; } &crate::PredeclaredType::AtomicCompareExchangeWeakResult { .. } => {} diff --git a/naga/src/back/wgsl/writer.rs b/naga/src/back/wgsl/writer.rs index 0f2635eb0..e8b942a62 100644 --- a/naga/src/back/wgsl/writer.rs +++ b/naga/src/back/wgsl/writer.rs @@ -1221,31 +1221,31 @@ impl Writer { match expressions[expr] { Expression::Literal(literal) => match literal { - crate::Literal::F32(value) => write!(self.out, "{}f", value)?, - crate::Literal::U32(value) => write!(self.out, "{}u", value)?, + crate::Literal::F32(value) => write!(self.out, "{value}f")?, + crate::Literal::U32(value) => write!(self.out, "{value}u")?, crate::Literal::I32(value) => { // `-2147483648i` is not valid WGSL. The most negative `i32` // value can only be expressed in WGSL using AbstractInt and // a unary negation operator. if value == i32::MIN { - write!(self.out, "i32({})", value)?; + write!(self.out, "i32({value})")?; } else { - write!(self.out, "{}i", value)?; + write!(self.out, "{value}i")?; } } - crate::Literal::Bool(value) => write!(self.out, "{}", value)?, - crate::Literal::F64(value) => write!(self.out, "{:?}lf", value)?, + crate::Literal::Bool(value) => write!(self.out, "{value}")?, + crate::Literal::F64(value) => write!(self.out, "{value:?}lf")?, crate::Literal::I64(value) => { // `-9223372036854775808li` is not valid WGSL. The most negative `i64` // value can only be expressed in WGSL using AbstractInt and // a unary negation operator. if value == i64::MIN { - write!(self.out, "i64({})", value)?; + write!(self.out, "i64({value})")?; } else { - write!(self.out, "{}li", value)?; + write!(self.out, "{value}li")?; } } - crate::Literal::U64(value) => write!(self.out, "{:?}lu", value)?, + crate::Literal::U64(value) => write!(self.out, "{value:?}lu")?, crate::Literal::AbstractInt(_) | crate::Literal::AbstractFloat(_) => { return Err(Error::Custom( "Abstract types should not appear in IR presented to backends".into(), diff --git a/naga/src/front/wgsl/error.rs b/naga/src/front/wgsl/error.rs index 3d4ac6218..a7986ec89 100644 --- a/naga/src/front/wgsl/error.rs +++ b/naga/src/front/wgsl/error.rs @@ -790,11 +790,11 @@ impl<'a> Error<'a> { Error::ConcretizationFailed(ref error) => { let ConcretizationFailedError { expr_span, ref expr_type, ref scalar, ref inner } = **error; ParseError { - message: format!("failed to convert expression to a concrete type: {}", inner), + message: format!("failed to convert expression to a concrete type: {inner}"), labels: vec![ ( expr_span, - format!("this expression has type {}", expr_type).into(), + format!("this expression has type {expr_type}").into(), ) ], notes: vec![ diff --git a/player/src/bin/play.rs b/player/src/bin/play.rs index 558eb194b..842a05148 100644 --- a/player/src/bin/play.rs +++ b/player/src/bin/play.rs @@ -91,7 +91,7 @@ fn main() { Some(queue_id), ); if let Err(e) = res { - panic!("{:?}", e); + panic!("{e:?}"); } (device_id, queue_id) } diff --git a/player/src/lib.rs b/player/src/lib.rs index 241c19096..3b0b4149a 100644 --- a/player/src/lib.rs +++ b/player/src/lib.rs @@ -237,7 +237,7 @@ impl GlobalPlay for wgc::global::Global { let module = ron::de::from_str(&code).unwrap(); wgc::pipeline::ShaderModuleSource::Naga(module) } else { - panic!("Unknown shader {}", data); + panic!("Unknown shader {data}"); }; let (_, error) = self.device_create_shader_module(device, &desc, source, Some(id)); if let Some(e) = error { diff --git a/player/tests/test.rs b/player/tests/test.rs index ec96f5446..107481b74 100644 --- a/player/tests/test.rs +++ b/player/tests/test.rs @@ -58,7 +58,7 @@ struct Test<'a> { fn map_callback(status: Result<(), wgc::resource::BufferAccessError>) { if let Err(e) = status { - panic!("Buffer map error: {}", e); + panic!("Buffer map error: {e}"); } } @@ -88,7 +88,7 @@ impl Test<'_> { .iter() .map(|feature| { wgt::Features::from_name(feature) - .unwrap_or_else(|| panic!("Invalid feature flag {}", feature)) + .unwrap_or_else(|| panic!("Invalid feature flag {feature}")) }) .fold(wgt::Features::empty(), |a, b| a | b); Test { @@ -120,7 +120,7 @@ impl Test<'_> { Some(queue_id), ); if let Err(e) = res { - panic!("{:?}", e); + panic!("{e:?}"); } let mut command_buffer_id_manager = wgc::identity::IdentityManager::new(); @@ -186,8 +186,7 @@ impl Test<'_> { if &expected_data[..] != contents { panic!( - "Test expectation is not met!\nBuffer content was:\n{:?}\nbut expected:\n{:?}", - contents, expected_data + "Test expectation is not met!\nBuffer content was:\n{contents:?}\nbut expected:\n{expected_data:?}" ); } } @@ -209,7 +208,7 @@ const BACKENDS: &[wgt::Backend] = &[ impl Corpus { fn run_from(path: PathBuf) { - println!("Corpus {:?}", path); + println!("Corpus {path:?}"); let dir = path.parent().unwrap(); let corpus: Corpus = ron::de::from_reader(File::open(&path).unwrap()).unwrap(); @@ -219,7 +218,7 @@ impl Corpus { } let mut test_num = 0; for test_path in &corpus.tests { - println!("\t\tTest '{:?}'", test_path); + println!("\t\tTest '{test_path:?}'"); let global = wgc::global::Global::new( "test", @@ -243,7 +242,7 @@ impl Corpus { Err(_) => continue, }; - println!("\tBackend {:?}", backend); + println!("\tBackend {backend:?}"); let supported_features = global.adapter_features(adapter); let downlevel_caps = global.adapter_downlevel_capabilities(adapter); diff --git a/tests/src/image.rs b/tests/src/image.rs index 602d93c4e..f1fe07b10 100644 --- a/tests/src/image.rs +++ b/tests/src/image.rs @@ -188,11 +188,10 @@ pub async fn compare_image_output( sanitize_for_path(&adapter_info.driver) ); // Determine the paths to write out the various intermediate files - let actual_path = Path::new(&path).with_file_name( - OsString::from_str(&format!("{}-{}-actual.png", file_stem, renderer)).unwrap(), - ); + let actual_path = Path::new(&path) + .with_file_name(OsString::from_str(&format!("{file_stem}-{renderer}-actual.png")).unwrap()); let difference_path = Path::new(&path).with_file_name( - OsString::from_str(&format!("{}-{}-difference.png", file_stem, renderer,)).unwrap(), + OsString::from_str(&format!("{file_stem}-{renderer}-difference.png",)).unwrap(), ); let mut all_passed; diff --git a/tests/src/params.rs b/tests/src/params.rs index e5d50a485..d3b7070f3 100644 --- a/tests/src/params.rs +++ b/tests/src/params.rs @@ -151,7 +151,7 @@ impl TestInfo { let names: ArrayVec<_, 4> = reasons.iter_names().map(|(name, _)| name).collect(); let names_text = names.join(" | "); - format!("Skipped Failure: {}", names_text) + format!("Skipped Failure: {names_text}") } else if !unsupported_reasons.is_empty() { skip = true; format!("Unsupported: {}", unsupported_reasons.join(" | ")) diff --git a/tests/tests/subgroup_operations/mod.rs b/tests/tests/subgroup_operations/mod.rs index ecf8adfd7..f874a6bac 100644 --- a/tests/tests/subgroup_operations/mod.rs +++ b/tests/tests/subgroup_operations/mod.rs @@ -123,10 +123,10 @@ static SUBGROUP_OPERATIONS: GpuTestConfiguration = GpuTestConfiguration::new() .enumerate() .filter(|(_, (r, e))| *r != e) { - write!(&mut msg, "thread {} failed tests:", thread).unwrap(); + write!(&mut msg, "thread {thread} failed tests:").unwrap(); let difference = result ^ expected; for i in (0..u32::BITS).filter(|i| (difference & (1 << i)) != 0) { - write!(&mut msg, " {},", i).unwrap(); + write!(&mut msg, " {i},").unwrap(); } writeln!(&mut msg).unwrap(); } diff --git a/tests/tests/vertex_formats/mod.rs b/tests/tests/vertex_formats/mod.rs index d447ac8f7..189120d4a 100644 --- a/tests/tests/vertex_formats/mod.rs +++ b/tests/tests/vertex_formats/mod.rs @@ -352,10 +352,7 @@ async fn vertex_formats_common(ctx: TestingContext, tests: &[Test<'_>]) { let mut deltas = data.iter().zip(expected.iter()).map(|(d, e)| (d - e).abs()); if deltas.any(|x| x > EPSILON) { - eprintln!( - "Failed: Got: {:?} Expected: {:?} - {case_name}", - data, expected, - ); + eprintln!("Failed: Got: {data:?} Expected: {expected:?} - {case_name}",); failed = true; continue; } diff --git a/tests/tests/vertex_indices/mod.rs b/tests/tests/vertex_indices/mod.rs index 5c5ce8a20..300a97eeb 100644 --- a/tests/tests/vertex_indices/mod.rs +++ b/tests/tests/vertex_indices/mod.rs @@ -471,10 +471,7 @@ async fn vertex_index_common(ctx: TestingContext) { test.case, test.id_source, test.draw_call_kind, test.encoder_kind ); if data != expected { - eprintln!( - "Failed: Got: {:?} Expected: {:?} - {case_name}", - data, expected, - ); + eprintln!("Failed: Got: {data:?} Expected: {expected:?} - {case_name}",); failed = true; } else { eprintln!("Passed: {case_name}"); diff --git a/wgpu-hal/src/vulkan/device.rs b/wgpu-hal/src/vulkan/device.rs index 6c3bfc5ed..9f0fc6773 100644 --- a/wgpu-hal/src/vulkan/device.rs +++ b/wgpu-hal/src/vulkan/device.rs @@ -2538,8 +2538,7 @@ impl super::DeviceShared { } None => { crate::hal_usage_error(format!( - "no signals reached value {}", - wait_value + "no signals reached value {wait_value}" )); } } diff --git a/wgpu-info/src/human.rs b/wgpu-info/src/human.rs index 24eeec000..8bbd4c006 100644 --- a/wgpu-info/src/human.rs +++ b/wgpu-info/src/human.rs @@ -230,7 +230,7 @@ fn print_adapter(output: &mut impl io::Write, report: &AdapterReport, idx: usize for format in TEXTURE_FORMAT_LIST { let features = texture_format_features[&format]; let format_name = texture::texture_format_name(format); - write!(output, "\t\t{format_name:>0$}", max_format_name_size)?; + write!(output, "\t\t{format_name:>max_format_name_size$}")?; for bit in wgpu::TextureUsages::all().iter() { write!(output, " │ ")?; if features.allowed_usages.contains(bit) { @@ -259,7 +259,7 @@ fn print_adapter(output: &mut impl io::Write, report: &AdapterReport, idx: usize let features = texture_format_features[&format]; let format_name = texture::texture_format_name(format); - write!(output, "\t\t{format_name:>0$}", max_format_name_size)?; + write!(output, "\t\t{format_name:>max_format_name_size$}")?; for bit in wgpu::TextureFormatFeatureFlags::all().iter() { write!(output, " │ ")?; if features.flags.contains(bit) { diff --git a/wgpu-macros/src/lib.rs b/wgpu-macros/src/lib.rs index 19eea678a..f8232c036 100644 --- a/wgpu-macros/src/lib.rs +++ b/wgpu-macros/src/lib.rs @@ -14,8 +14,8 @@ pub fn gpu_test(_attr: TokenStream, item: TokenStream) -> TokenStream { let ident_str = ident.to_string(); let ident_lower = ident_str.to_snake_case(); - let register_test_name = Ident::new(&format!("{}_initializer", ident_lower), ident.span()); - let test_name_webgl = Ident::new(&format!("{}_webgl", ident_lower), ident.span()); + let register_test_name = Ident::new(&format!("{ident_lower}_initializer"), ident.span()); + let test_name_webgl = Ident::new(&format!("{ident_lower}_webgl"), ident.span()); quote! { #[cfg(not(target_arch = "wasm32"))] diff --git a/wgpu/src/backend/wgpu_core.rs b/wgpu/src/backend/wgpu_core.rs index 1d1ffda20..652df388f 100644 --- a/wgpu/src/backend/wgpu_core.rs +++ b/wgpu/src/backend/wgpu_core.rs @@ -359,7 +359,7 @@ impl ContextWgpuCore { print_tree(&mut output, &mut level, err); - format!("Validation Error\n\nCaused by:\n{}", output) + format!("Validation Error\n\nCaused by:\n{output}") } }