diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1dea4069e..51a86219c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -25,7 +25,7 @@ env: MESA_VERSION: "24.3.4" # This is the MSRV used by `wgpu` itself and all surrounding infrastructure. - REPO_MSRV: "1.84" + REPO_MSRV: "1.88" # This is the MSRV used by the `wgpu-core`, `wgpu-hal`, and `wgpu-types` crates, # to ensure that they can be used with firefox. CORE_MSRV: "1.82.0" diff --git a/.github/workflows/cts.yml b/.github/workflows/cts.yml index d5e989504..aeedd3df9 100644 --- a/.github/workflows/cts.yml +++ b/.github/workflows/cts.yml @@ -11,7 +11,7 @@ env: CARGO_INCREMENTAL: false CARGO_TERM_COLOR: always RUST_BACKTRACE: full - MSRV: "1.84" + MSRV: "1.88" jobs: cts: diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index d96ed0870..ac97b7710 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -10,7 +10,7 @@ on: env: # This is the MSRV used by `wgpu` itself and all surrounding infrastructure. - REPO_MSRV: "1.84" + REPO_MSRV: "1.88" CARGO_INCREMENTAL: false CARGO_TERM_COLOR: always diff --git a/.github/workflows/generate.yml b/.github/workflows/generate.yml index 0f758d4a8..a3f0fb18f 100644 --- a/.github/workflows/generate.yml +++ b/.github/workflows/generate.yml @@ -13,7 +13,7 @@ env: # # This is the MSRV used by `wgpu` itself and all surrounding infrastructure. - REPO_MSRV: "1.84" + REPO_MSRV: "1.88" RUSTFLAGS: -D warnings jobs: diff --git a/Cargo.toml b/Cargo.toml index ca7f4121e..444bb9aa7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -54,7 +54,7 @@ ref_as_ptr = "warn" [workspace.package] edition = "2021" -rust-version = "1.84" +rust-version = "1.88" keywords = ["graphics"] license = "MIT OR Apache-2.0" homepage = "https://wgpu.rs/" @@ -178,7 +178,7 @@ rustc-hash = { version = "1.1", default-features = false } serde_json = "1.0.118" serde = { version = "1.0.219", default-features = false } shell-words = "1" -smallvec = "1.9" +smallvec = "1.13.1" spirv = "0.3" static_assertions = "1.1" strum = { version = "0.27", default-features = false, features = ["derive"] } diff --git a/README.md b/README.md index ac984583e..511427394 100644 --- a/README.md +++ b/README.md @@ -149,8 +149,8 @@ On Linux, you can point to them using `LD_LIBRARY_PATH` environment. Due to complex dependants, we have two MSRV policies: -- `naga`, `wgpu-core`, `wgpu-hal`, and `wgpu-types`'s MSRV is **1.76**. -- The rest of the workspace has an MSRV of **1.84**. +- `naga`, `wgpu-core`, `wgpu-hal`, and `wgpu-types`'s MSRV is **1.82**. +- The rest of the workspace has an MSRV of **1.88**. It is enforced on CI (in "/.github/workflows/ci.yml") with the `CORE_MSRV` and `REPO_MSRV` variables. This version can only be upgraded in breaking releases, though we release a breaking version every three months. diff --git a/benches/benches/wgpu-benchmark/bind_groups.rs b/benches/benches/wgpu-benchmark/bind_groups.rs index 6fb23d0a2..50245d441 100644 --- a/benches/benches/wgpu-benchmark/bind_groups.rs +++ b/benches/benches/wgpu-benchmark/bind_groups.rs @@ -87,7 +87,7 @@ fn run_bench(ctx: &mut Criterion) { for &count in count_list { group.throughput(Throughput::Elements(count as u64)); group.bench_with_input( - format!("{} Element Bind Group", count), + format!("{count} Element Bind Group"), &count, |b, &count| { b.iter_custom(|iters| { diff --git a/clippy.toml b/clippy.toml index 35f212da6..1910b9fcb 100644 --- a/clippy.toml +++ b/clippy.toml @@ -3,6 +3,4 @@ disallowed-types = [ { path = "std::collections::HashMap", reason = "use hashbrown::HashMap instead" }, { path = "std::collections::HashSet", reason = "use hashbrown::HashSet instead" }, - { path = "rustc_hash::FxHashMap", reason = "use hashbrown::HashMap instead" }, - { path = "rustc_hash::FxHashSet", reason = "use hashbrown::HashSet instead" }, ] diff --git a/cts_runner/test.lst b/cts_runner/test.lst index 78aae8713..a34aa4b37 100644 --- a/cts_runner/test.lst +++ b/cts_runner/test.lst @@ -68,7 +68,7 @@ webgpu:api,operation,rendering,color_target_state:blend_constant,setting:* webgpu:api,operation,rendering,depth:* webgpu:api,operation,rendering,draw:* webgpu:api,operation,shader_module,compilation_info:* -webgpu:api,operation,uncapturederror:iff_uncaptured:* +fails-if(metal) webgpu:api,operation,uncapturederror:iff_uncaptured:* //FAIL: webgpu:shader,execution,expression,call,builtin,select:* // - Fails with `const`/abstract int cases on all platforms because of . // - Fails with `vec3` & `f16` cases on macOS because of . diff --git a/examples/features/src/big_compute_buffers/mod.rs b/examples/features/src/big_compute_buffers/mod.rs index 905612718..579ab8a79 100644 --- a/examples/features/src/big_compute_buffers/mod.rs +++ b/examples/features/src/big_compute_buffers/mod.rs @@ -193,7 +193,7 @@ fn create_storage_buffers(device: &wgpu::Device, numbers: &[f32]) -> Vec Vec wgpu::RenderBundle { - log::info!("sample_count: {}", sample_count); + log::info!("sample_count: {sample_count}"); let pipeline = device.create_render_pipeline(&wgpu::RenderPipelineDescriptor { label: None, layout: Some(pipeline_layout), diff --git a/examples/features/src/ray_cube_compute/mod.rs b/examples/features/src/ray_cube_compute/mod.rs index 522a6e75c..9492822ad 100644 --- a/examples/features/src/ray_cube_compute/mod.rs +++ b/examples/features/src/ray_cube_compute/mod.rs @@ -114,7 +114,7 @@ impl>> Future for ErrorFuture { let inner = unsafe { self.map_unchecked_mut(|me| &mut me.inner) }; inner.poll(cx).map(|error| { if let Some(e) = error { - panic!("Rendering {}", e); + panic!("Rendering {e}"); } }) } diff --git a/examples/features/src/ray_cube_fragment/mod.rs b/examples/features/src/ray_cube_fragment/mod.rs index 1dd1ae90d..94db6b59f 100644 --- a/examples/features/src/ray_cube_fragment/mod.rs +++ b/examples/features/src/ray_cube_fragment/mod.rs @@ -89,7 +89,7 @@ impl>> Future for ErrorFuture { let inner = unsafe { self.map_unchecked_mut(|me| &mut me.inner) }; inner.poll(cx).map(|error| { if let Some(e) = error { - panic!("Rendering {}", e); + panic!("Rendering {e}"); } }) } diff --git a/examples/features/src/ray_cube_normals/mod.rs b/examples/features/src/ray_cube_normals/mod.rs index 66a56d75b..e21974eab 100644 --- a/examples/features/src/ray_cube_normals/mod.rs +++ b/examples/features/src/ray_cube_normals/mod.rs @@ -113,7 +113,7 @@ impl>> Future for ErrorFuture { let inner = unsafe { self.map_unchecked_mut(|me| &mut me.inner) }; inner.poll(cx).map(|error| { if let Some(e) = error { - panic!("Rendering {}", e); + panic!("Rendering {e}"); } }) } diff --git a/examples/features/src/ray_scene/mod.rs b/examples/features/src/ray_scene/mod.rs index 765705cb8..66717c5a8 100644 --- a/examples/features/src/ray_scene/mod.rs +++ b/examples/features/src/ray_scene/mod.rs @@ -41,7 +41,7 @@ impl>> Future for ErrorFuture { let inner = unsafe { self.map_unchecked_mut(|me| &mut me.inner) }; inner.poll(cx).map(|error| { if let Some(e) = error { - panic!("Rendering {}", e); + panic!("Rendering {e}"); } }) } @@ -93,7 +93,7 @@ struct Material { fn load_model(scene: &mut RawSceneComponents, path: &str) { let path = env!("CARGO_MANIFEST_DIR").to_string() + "/src" + path; - println!("{}", path); + println!("{path}"); let mut object = obj::Obj::load(path).unwrap(); object.load_mtls().unwrap(); diff --git a/examples/features/src/ray_shadows/mod.rs b/examples/features/src/ray_shadows/mod.rs index 8ba14c399..8b93fb275 100644 --- a/examples/features/src/ray_shadows/mod.rs +++ b/examples/features/src/ray_shadows/mod.rs @@ -68,7 +68,7 @@ impl>> Future for ErrorFuture { let inner = unsafe { self.map_unchecked_mut(|me| &mut me.inner) }; inner.poll(cx).map(|error| { if let Some(e) = error { - panic!("Rendering {}", e); + panic!("Rendering {e}"); } }) } diff --git a/examples/features/src/skybox/mod.rs b/examples/features/src/skybox/mod.rs index 38b0e1906..2484e6f25 100644 --- a/examples/features/src/skybox/mod.rs +++ b/examples/features/src/skybox/mod.rs @@ -299,11 +299,7 @@ impl crate::framework::Example for Example { let max_mips = layer_size.max_mips(wgpu::TextureDimension::D2); log::debug!( - "Copying {:?} skybox images of size {}, {}, 6 with {} mips to gpu", - skybox_format, - IMAGE_SIZE, - IMAGE_SIZE, - max_mips, + "Copying {skybox_format:?} skybox images of size {IMAGE_SIZE}, {IMAGE_SIZE}, 6 with {max_mips} mips to gpu", ); let bytes = match skybox_format { diff --git a/examples/features/src/utils.rs b/examples/features/src/utils.rs index e0c4b4f23..5d2913c18 100644 --- a/examples/features/src/utils.rs +++ b/examples/features/src/utils.rs @@ -37,7 +37,7 @@ pub fn output_image_native(image_data: Vec, texture_dims: (usize, usize), pa let mut file = std::fs::File::create(&path).unwrap(); file.write_all(&png_data[..]).unwrap(); - log::info!("PNG file written to disc as \"{}\".", path); + log::info!("PNG file written to disc as \"{path}\"."); } /// Effectively a version of `output_image_native` but meant for web browser contexts. @@ -58,9 +58,8 @@ pub fn output_image_wasm(image_data: Vec, texture_dims: (usize, usize)) { Err(e) => { log::error!( "In searching for a staging canvas for outputting an image \ - (element with id \"staging-canvas\"), found non-canvas element: {:?}. - Replacing with standard staging canvas.", - e + (element with id \"staging-canvas\"), found non-canvas element: {e:?}. + Replacing with standard staging canvas." ); e.remove(); create_staging_canvas(&document) @@ -101,9 +100,8 @@ pub fn output_image_wasm(image_data: Vec, texture_dims: (usize, usize)) { Ok(e) => e, Err(e) => { log::error!( - "Found an element with the id \"output-image-target\" but it was not an image: {:?}. + "Found an element with the id \"output-image-target\" but it was not an image: {e:?}. Replacing with default image output element.", - e ); e.remove(); create_output_image_element(&document) diff --git a/examples/standalone/01_hello_compute/Cargo.toml b/examples/standalone/01_hello_compute/Cargo.toml index 35c61745e..448c6c59e 100644 --- a/examples/standalone/01_hello_compute/Cargo.toml +++ b/examples/standalone/01_hello_compute/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "wgpu-example-01-hello-compute" edition = "2021" -rust-version = "1.84" +rust-version = "1.88" publish = false [dependencies] diff --git a/examples/standalone/01_hello_compute/src/main.rs b/examples/standalone/01_hello_compute/src/main.rs index 19d95620c..4a1f03465 100644 --- a/examples/standalone/01_hello_compute/src/main.rs +++ b/examples/standalone/01_hello_compute/src/main.rs @@ -249,5 +249,5 @@ fn main() { let result: &[f32] = bytemuck::cast_slice(&data); // Print out the result. - println!("Result: {:?}", result); + println!("Result: {result:?}"); } diff --git a/examples/standalone/02_hello_window/Cargo.toml b/examples/standalone/02_hello_window/Cargo.toml index 35385e6e2..8640c143f 100644 --- a/examples/standalone/02_hello_window/Cargo.toml +++ b/examples/standalone/02_hello_window/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "wgpu-example-02-hello-window" edition = "2021" -rust-version = "1.84" +rust-version = "1.88" publish = false [dependencies] diff --git a/examples/standalone/custom_backend/Cargo.toml b/examples/standalone/custom_backend/Cargo.toml index eb0142a1f..47e52290e 100644 --- a/examples/standalone/custom_backend/Cargo.toml +++ b/examples/standalone/custom_backend/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "wgpu-example-custom-backend" edition = "2021" -rust-version = "1.84" +rust-version = "1.88" publish = false [features] diff --git a/naga/src/back/dot/mod.rs b/naga/src/back/dot/mod.rs index c9fc49fe1..826dad1c2 100644 --- a/naga/src/back/dot/mod.rs +++ b/naga/src/back/dot/mod.rs @@ -740,7 +740,7 @@ fn write_function_expressions( E::RayQueryVertexPositions { query, committed } => { edges.insert("", query); let ty = if committed { "Committed" } else { "Candidate" }; - (format!("get{}HitVertexPositions", ty).into(), 4) + (format!("get{ty}HitVertexPositions").into(), 4) } }; diff --git a/naga/src/back/glsl/mod.rs b/naga/src/back/glsl/mod.rs index ee0daa89c..75917fb76 100644 --- a/naga/src/back/glsl/mod.rs +++ b/naga/src/back/glsl/mod.rs @@ -1238,7 +1238,7 @@ impl<'a, W: Write> Writer<'a, W> { write!(self.out, "layout(")?; if let Some(layout) = layout { - write!(self.out, "{}, ", layout)?; + write!(self.out, "{layout}, ")?; } write!(self.out, "binding = {binding}) ")?; @@ -1255,7 +1255,7 @@ impl<'a, W: Write> Writer<'a, W> { // Either no explicit bindings are supported or we didn't have any. // Write just the memory layout. if let Some(layout) = layout { - write!(self.out, "layout({}) ", layout)?; + write!(self.out, "layout({layout}) ")?; } Ok(()) @@ -3698,11 +3698,11 @@ impl<'a, W: Write> Writer<'a, W> { // `Dot4U8Packed`, the code below only introduces parenthesis around // each factor, which aren't strictly needed because both operands are // baked, but which don't hurt either. - write!(self.out, "bitfieldExtract({}(", conversion)?; + write!(self.out, "bitfieldExtract({conversion}(")?; self.write_expr(arg, ctx)?; write!(self.out, "), {}, 8)", i * 8)?; - write!(self.out, " * bitfieldExtract({}(", conversion)?; + write!(self.out, " * bitfieldExtract({conversion}(")?; self.write_expr(arg1, ctx)?; write!(self.out, "), {}, 8)", i * 8)?; diff --git a/naga/src/back/hlsl/writer.rs b/naga/src/back/hlsl/writer.rs index 75e890d27..2f98b1fbf 100644 --- a/naga/src/back/hlsl/writer.rs +++ b/naga/src/back/hlsl/writer.rs @@ -317,7 +317,7 @@ impl<'a, W: fmt::Write> super::Writer<'a, W> { } for (group, bt) in self.options.dynamic_storage_buffer_offsets_targets.iter() { - writeln!(self.out, "struct __dynamic_buffer_offsetsTy{} {{", group)?; + writeln!(self.out, "struct __dynamic_buffer_offsetsTy{group} {{")?; for i in 0..bt.size { writeln!(self.out, "{}uint _{};", back::INDENT, i)?; } @@ -706,7 +706,7 @@ impl<'a, W: fmt::Write> super::Writer<'a, W> { let members = match module.types[result.ty].inner { TypeInner::Struct { ref members, .. } => members, ref other => { - log::error!("Unexpected {:?} output type without a binding", other); + log::error!("Unexpected {other:?} output type without a binding"); &empty[..] } }; @@ -1433,7 +1433,7 @@ impl<'a, W: fmt::Write> super::Writer<'a, W> { let array_return_type = self.namer.call(&format!("ret_{name}")); write!(self.out, "typedef ")?; self.write_type(module, result.ty)?; - write!(self.out, " {}", array_return_type)?; + write!(self.out, " {array_return_type}")?; self.write_array_size(module, base, size)?; writeln!(self.out, ";")?; Some(array_return_type) diff --git a/naga/src/back/msl/writer.rs b/naga/src/back/msl/writer.rs index 3cb1ab2c3..ce83b08dc 100644 --- a/naga/src/back/msl/writer.rs +++ b/naga/src/back/msl/writer.rs @@ -1150,7 +1150,7 @@ impl Writer { //TODO: do we support Zero on `Sampled` image classes? } _ if !has_levels => { - log::warn!("1D image can't be sampled with level {:?}", level); + log::warn!("1D image can't be sampled with level {level:?}"); } crate::SampleLevel::Exact(h) => { write!(self.out, ", {NAMESPACE}::level(")?; @@ -1397,7 +1397,7 @@ impl Writer { } else { fun.to_msl() }; - write!(self.out, ".atomic_{}(", op)?; + write!(self.out, ".atomic_{op}(")?; // coordinates in IR are int, but Metal expects uint self.put_cast_to_uint_scalar_or_vector(address.coordinate, &context.expression)?; write!(self.out, ", ")?; @@ -2352,7 +2352,7 @@ impl Writer { arg1.unwrap(), 4, |writer, arg, index| { - write!(writer.out, "({}(", conversion)?; + write!(writer.out, "({conversion}(")?; writer.put_expression(arg, context, true)?; if index == 3 { write!(writer.out, ") >> 24)")?; @@ -3420,7 +3420,7 @@ impl Writer { put_numeric_type(&mut self.out, scalar, &[rows, columns])?; } TypeResolution::Value(ref other) => { - log::warn!("Type {:?} isn't a known local", other); //TEMP! + log::warn!("Type {other:?} isn't a known local"); //TEMP! return Err(Error::FeatureNotImplemented("weird local type".to_string())); } } diff --git a/naga/src/back/spv/block.rs b/naga/src/back/spv/block.rs index 7ec659e1d..71487c697 100644 --- a/naga/src/back/spv/block.rs +++ b/naga/src/back/spv/block.rs @@ -675,7 +675,7 @@ impl BlockContext<'_> { load_id } ref other => { - log::error!("Unable to access index of {:?}", other); + log::error!("Unable to access index of {other:?}"); return Err(Error::FeatureNotImplemented("access index for type")); } } @@ -1893,7 +1893,7 @@ impl BlockContext<'_> { crate::TypeInner::Scalar(scalar) => (scalar, None), crate::TypeInner::Vector { scalar, size } => (scalar, Some(size)), ref other => { - log::error!("As source {:?}", other); + log::error!("As source {other:?}"); return Err(Error::Validation("Unexpected Expression::As source")); } }; diff --git a/naga/src/back/spv/helpers.rs b/naga/src/back/spv/helpers.rs index 7938791ba..84e130efa 100644 --- a/naga/src/back/spv/helpers.rs +++ b/naga/src/back/spv/helpers.rs @@ -35,6 +35,9 @@ pub(super) fn string_to_byte_chunks(input: &str, limit: usize) -> Vec<&[u8]> { let mut words = vec![]; while offset < input.len() { offset = input.floor_char_boundary(offset + limit); + // Clippy wants us to call as_bytes() first to avoid the UTF-8 check, + // but we want to assert the output is valid UTF-8. + #[allow(clippy::sliced_string_as_bytes)] words.push(input[start..offset].as_bytes()); start = offset; } diff --git a/naga/src/back/spv/image.rs b/naga/src/back/spv/image.rs index f48501453..faac98287 100644 --- a/naga/src/back/spv/image.rs +++ b/naga/src/back/spv/image.rs @@ -303,7 +303,7 @@ impl BlockContext<'_> { return Err(Error::Validation("extending vec4 coordinate")); } ref other => { - log::error!("wrong coordinate type {:?}", other); + log::error!("wrong coordinate type {other:?}"); return Err(Error::Validation("coordinate type")); } }; diff --git a/naga/src/back/spv/index.rs b/naga/src/back/spv/index.rs index 45d628e0f..3a15ee880 100644 --- a/naga/src/back/spv/index.rs +++ b/naga/src/back/spv/index.rs @@ -277,7 +277,7 @@ impl BlockContext<'_> { Ok(MaybeKnown::Computed(length_id)) } Err(err) => { - log::error!("Sequence length for {:?} failed: {}", sequence, err); + log::error!("Sequence length for {sequence:?} failed: {err}"); Err(Error::Validation("indexable length")) } } diff --git a/naga/src/common/wgsl/types.rs b/naga/src/common/wgsl/types.rs index c118feeac..1c20d9672 100644 --- a/naga/src/common/wgsl/types.rs +++ b/naga/src/common/wgsl/types.rs @@ -337,7 +337,7 @@ where } => { let (address, maybe_access) = address_space_str(space); if let Some(space) = address { - write!(out, "ptr<{}, ", space)?; + write!(out, "ptr<{space}, ")?; ctx.write_scalar(scalar, out)?; if let Some(access) = maybe_access { write!(out, ", {access}")?; @@ -368,14 +368,14 @@ where } TypeInner::AccelerationStructure { vertex_return } => { let caps = if vertex_return { "" } else { "" }; - write!(out, "acceleration_structure{}", caps)? + write!(out, "acceleration_structure{caps}")? } TypeInner::Struct { .. } => { ctx.write_unnamed_struct(inner, out)?; } TypeInner::RayQuery { vertex_return } => { let caps = if vertex_return { "" } else { "" }; - write!(out, "ray_query{}", caps)? + write!(out, "ray_query{caps}")? } } diff --git a/naga/src/compact/expressions.rs b/naga/src/compact/expressions.rs index 24562bdd4..f36d747a9 100644 --- a/naga/src/compact/expressions.rs +++ b/naga/src/compact/expressions.rs @@ -68,7 +68,7 @@ impl ExpressionTracer<'_> { continue; } - log::trace!("tracing new expression {:?}", expr); + log::trace!("tracing new expression {expr:?}"); self.trace_expression(expr); } } diff --git a/naga/src/compact/handle_set_map.rs b/naga/src/compact/handle_set_map.rs index 7a174cd91..b3cbb909e 100644 --- a/naga/src/compact/handle_set_map.rs +++ b/naga/src/compact/handle_set_map.rs @@ -37,7 +37,7 @@ impl HandleMap { if self.new_index.len() <= handle.index() { self.new_index.resize_with(handle.index() + 1, || None); } - core::mem::replace(&mut self.new_index[handle.index()], Some(value)) + self.new_index[handle.index()].replace(value) } } diff --git a/naga/src/compact/mod.rs b/naga/src/compact/mod.rs index c7b7bfb46..48972dc64 100644 --- a/naga/src/compact/mod.rs +++ b/naga/src/compact/mod.rs @@ -164,7 +164,7 @@ pub fn compact(module: &mut crate::Module, keep_unused: KeepUnused) { } while let Some(handle) = module_tracer.functions_pending.pop() { let function = &module.functions[handle]; - log::trace!("tracing function {:?}", function); + log::trace!("tracing function {function:?}"); let mut function_tracer = module_tracer.as_function(function); function_tracer.trace(); function_maps.insert(handle, FunctionMap::from(function_tracer)); @@ -680,7 +680,7 @@ fn type_expression_interdependence() { }; let mut type_name_counter = 0; let mut type_needed = |module: &mut crate::Module, handle| { - let name = Some(format!("type{}", type_name_counter)); + let name = Some(format!("type{type_name_counter}")); type_name_counter += 1; module.types.insert( crate::Type { @@ -696,7 +696,7 @@ fn type_expression_interdependence() { }; let mut override_name_counter = 0; let mut expression_needed = |module: &mut crate::Module, handle| { - let name = Some(format!("override{}", override_name_counter)); + let name = Some(format!("override{override_name_counter}")); override_name_counter += 1; module.overrides.append( crate::Override { diff --git a/naga/src/error.rs b/naga/src/error.rs index 597aad992..3c2f476c9 100644 --- a/naga/src/error.rs +++ b/naga/src/error.rs @@ -56,7 +56,7 @@ impl fmt::Display for ShaderError writer.into_string() }; - write!(f, "\nShader validation {}", writer) + write!(f, "\nShader validation {writer}") } } diff --git a/naga/src/front/glsl/context.rs b/naga/src/front/glsl/context.rs index e6c5546fb..d65004499 100644 --- a/naga/src/front/glsl/context.rs +++ b/naga/src/front/glsl/context.rs @@ -541,7 +541,7 @@ impl<'a> Context<'a> { ) -> Result<(Option>, Span)> { let HirExpr { ref kind, meta } = stmt.hir_exprs[expr]; - log::debug!("Lowering {:?} (kind {:?}, pos {:?})", expr, kind, pos); + log::debug!("Lowering {expr:?} (kind {kind:?}, pos {pos:?})"); let handle = match *kind { HirExprKind::Access { base, index } => { @@ -636,8 +636,7 @@ impl<'a> Context<'a> { frontend.errors.push(Error { kind: ErrorKind::SemanticError( format!( - "Cannot apply operation to {:?} and {:?}", - left_inner, right_inner + "Cannot apply operation to {left_inner:?} and {right_inner:?}" ) .into(), ), @@ -835,8 +834,7 @@ impl<'a> Context<'a> { frontend.errors.push(Error { kind: ErrorKind::SemanticError( format!( - "Cannot apply operation to {:?} and {:?}", - left_inner, right_inner + "Cannot apply operation to {left_inner:?} and {right_inner:?}" ) .into(), ), @@ -916,8 +914,7 @@ impl<'a> Context<'a> { frontend.errors.push(Error { kind: ErrorKind::SemanticError( format!( - "Cannot apply operation to {:?} and {:?}", - left_inner, right_inner + "Cannot apply operation to {left_inner:?} and {right_inner:?}" ) .into(), ), @@ -1339,13 +1336,7 @@ impl<'a> Context<'a> { } }; - log::trace!( - "Lowered {:?}\n\tKind = {:?}\n\tPos = {:?}\n\tResult = {:?}", - expr, - kind, - pos, - handle - ); + log::trace!("Lowered {expr:?}\n\tKind = {kind:?}\n\tPos = {pos:?}\n\tResult = {handle:?}"); Ok((Some(handle), meta)) } diff --git a/naga/src/front/glsl/functions.rs b/naga/src/front/glsl/functions.rs index e0a0535a0..7de7364cd 100644 --- a/naga/src/front/glsl/functions.rs +++ b/naga/src/front/glsl/functions.rs @@ -560,7 +560,7 @@ impl Frontend { continue; } - log::trace!("Testing overload {}", overload_idx); + log::trace!("Testing overload {overload_idx}"); // Stores whether the current overload matches exactly the function call let mut exact = true; @@ -592,10 +592,7 @@ impl Frontend { let call_arg_ty = ctx.get_type(call_argument.0); log::trace!( - "Testing parameter {}\n\tOverload = {:?}\n\tCall = {:?}", - i, - overload_param_ty, - call_arg_ty + "Testing parameter {i}\n\tOverload = {overload_param_ty:?}\n\tCall = {call_arg_ty:?}" ); // Storage images cannot be directly compared since while the access is part of the @@ -641,8 +638,7 @@ impl Frontend { self.errors.push(Error { kind: ErrorKind::SemanticError( format!( - "'{}': image needs {:?} access but only {:?} was provided", - name, overload_access, call_access + "'{name}': image needs {overload_access:?} access but only {call_access:?} was provided" ) .into(), ), diff --git a/naga/src/front/mod.rs b/naga/src/front/mod.rs index 4f363d897..826100e87 100644 --- a/naga/src/front/mod.rs +++ b/naga/src/front/mod.rs @@ -114,7 +114,7 @@ impl Typifier { for (eh, expr) in expressions.iter().skip(self.resolutions.len()) { //Note: the closure can't `Err` by construction let resolution = ctx.resolve(expr, |h| Ok(&self.resolutions[h]))?; - log::debug!("Resolving {:?} = {:?} : {:?}", eh, expr, resolution); + log::debug!("Resolving {eh:?} = {expr:?} : {resolution:?}"); self.resolutions.insert(eh, resolution); } } diff --git a/naga/src/front/spv/function.rs b/naga/src/front/spv/function.rs index 13163f6bd..1e581368e 100644 --- a/naga/src/front/spv/function.rs +++ b/naga/src/front/spv/function.rs @@ -167,7 +167,7 @@ impl> super::Frontend { if let Some(ref prefix) = self.options.block_ctx_dump_prefix { let dump_suffix = match self.lookup_entry_point.get(&fun_id) { Some(ep) => format!("block_ctx.{:?}-{}.txt", ep.stage, ep.name), - None => format!("block_ctx.Fun-{}.txt", function_index), + None => format!("block_ctx.Fun-{function_index}.txt"), }; cfg_if::cfg_if! { @@ -176,10 +176,10 @@ impl> super::Frontend { let dest = prefix.join(dump_suffix); let dump = format!("{block_ctx:#?}"); if let Err(e) = std::fs::write(&dest, dump) { - log::error!("Unable to dump the block context into {:?}: {}", dest, e); + log::error!("Unable to dump the block context into {dest:?}: {e}"); } } else { - log::error!("Unable to dump the block context into {:?}/{}: file system integration was not enabled with the `fs` feature", prefix, dump_suffix); + log::error!("Unable to dump the block context into {prefix:?}/{dump_suffix}: file system integration was not enabled with the `fs` feature"); } } } @@ -191,7 +191,7 @@ impl> super::Frontend { // to get the spill. for phi in block_ctx.phis.iter() { // Get a pointer to the local variable for the phi's value. - let phi_pointer = block_ctx.expressions.append( + let phi_pointer: Handle = block_ctx.expressions.append( crate::Expression::LocalVariable(phi.local), crate::Span::default(), ); diff --git a/naga/src/front/spv/image.rs b/naga/src/front/spv/image.rs index 15dafa5af..ee94fe6ef 100644 --- a/naga/src/front/spv/image.rs +++ b/naga/src/front/spv/image.rs @@ -202,7 +202,7 @@ pub(super) fn patch_comparison_type( return false; } - log::debug!("Flipping comparison for {:?}", var); + log::debug!("Flipping comparison for {var:?}"); let original_ty = &arena[var.ty]; let original_ty_span = arena.get_span(var.ty); let ty_inner = match original_ty.inner { @@ -279,7 +279,7 @@ impl> super::Frontend { if image_ops != 0 { let other = spirv::ImageOperands::from_bits_truncate(image_ops); - log::warn!("Unknown image write ops {:?}", other); + log::warn!("Unknown image write ops {other:?}"); for _ in 1..words_left { self.next()?; } @@ -403,7 +403,7 @@ impl> super::Frontend { words_left -= 1; } other => { - log::warn!("Unknown image load op {:?}", other); + log::warn!("Unknown image load op {other:?}"); for _ in 0..words_left { self.next()?; } @@ -546,12 +546,11 @@ impl> super::Frontend { }; level = if options.compare { - log::debug!("Assuming {:?} is zero", lod_handle); + log::debug!("Assuming {lod_handle:?} is zero"); crate::SampleLevel::Zero } else if is_depth_image { log::debug!( - "Assuming level {:?} converts losslessly to an integer", - lod_handle + "Assuming level {lod_handle:?} converts losslessly to an integer" ); let expr = crate::Expression::As { expr: lod_handle, @@ -588,9 +587,7 @@ impl> super::Frontend { ); level = if options.compare { log::debug!( - "Assuming gradients {:?} and {:?} are not greater than 1", - grad_x_handle, - grad_y_handle + "Assuming gradients {grad_x_handle:?} and {grad_y_handle:?} are not greater than 1" ); crate::SampleLevel::Zero } else { @@ -616,7 +613,7 @@ impl> super::Frontend { words_left -= 1; } other => { - log::warn!("Unknown image sample operand {:?}", other); + log::warn!("Unknown image sample operand {other:?}"); for _ in 0..words_left { self.next()?; } diff --git a/naga/src/front/spv/mod.rs b/naga/src/front/spv/mod.rs index 2375e61c5..960437ece 100644 --- a/naga/src/front/spv/mod.rs +++ b/naga/src/front/spv/mod.rs @@ -515,7 +515,6 @@ enum MergeBlockInformation { /// [`blocks`]: BlockContext::blocks /// [`bodies`]: BlockContext::bodies /// [`phis`]: BlockContext::phis -/// [`lower`]: function::lower #[derive(Debug)] struct BlockContext<'function> { /// Phi nodes encountered when parsing the function, used to generate spills @@ -796,7 +795,7 @@ impl> Frontend { dec.specialization_constant_id = Some(self.next()?); } other => { - log::warn!("Unknown decoration {:?}", other); + log::warn!("Unknown decoration {other:?}"); for _ in base_words + 1..inst.wc { let _var = self.next()?; } @@ -1387,7 +1386,7 @@ impl> Frontend { block: &mut crate::Block, body_idx: usize, ) -> Result<(Handle, Handle), Error> { - log::trace!("\t\t\tlooking up pointer expr {:?}", pointer_id); + log::trace!("\t\t\tlooking up pointer expr {pointer_id:?}"); let p_lexp_handle; let p_lexp_ty_id; { @@ -1600,7 +1599,7 @@ impl> Frontend { .remove(&result_id) .and_then(|decor| decor.name); if let Some(ref name) = name { - log::debug!("\t\t\tid={} name={}", result_id, name); + log::debug!("\t\t\tid={result_id} name={name}"); } let lookup_ty = self.lookup_type.lookup(result_type_id)?; let var_handle = ctx.local_arena.append( @@ -1686,7 +1685,7 @@ impl> Frontend { let result_type_id = self.next()?; let result_id = self.next()?; let base_id = self.next()?; - log::trace!("\t\t\tlooking up expr {:?}", base_id); + log::trace!("\t\t\tlooking up expr {base_id:?}"); let mut acex = { let lexp = self.lookup_expression.lookup(base_id)?; @@ -1721,7 +1720,7 @@ impl> Frontend { for _ in 4..inst.wc { let access_id = self.next()?; - log::trace!("\t\t\tlooking up index expr {:?}", access_id); + log::trace!("\t\t\tlooking up index expr {access_id:?}"); let index_expr = self.lookup_expression.lookup(access_id)?.clone(); let index_expr_handle = get_expr_handle!(access_id, &index_expr); let index_expr_data = &ctx.expressions[index_expr.handle]; @@ -2064,7 +2063,7 @@ impl> Frontend { let result_type_id = self.next()?; let result_id = self.next()?; let base_id = self.next()?; - log::trace!("\t\t\tlooking up expr {:?}", base_id); + log::trace!("\t\t\tlooking up expr {base_id:?}"); let mut lexp = self.lookup_expression.lookup(base_id)?.clone(); lexp.handle = get_expr_handle!(base_id, &lexp); for _ in 4..inst.wc { @@ -2084,7 +2083,7 @@ impl> Frontend { .base_id .ok_or(Error::InvalidAccessType(lexp.type_id))?, ref other => { - log::warn!("composite type {:?}", other); + log::warn!("composite type {other:?}"); return Err(Error::UnsupportedType(type_lookup.handle)); } }; @@ -2153,7 +2152,7 @@ impl> Frontend { let mut components = Vec::with_capacity(inst.wc as usize - 2); for _ in 3..inst.wc { let comp_id = self.next()?; - log::trace!("\t\t\tlooking up expr {:?}", comp_id); + log::trace!("\t\t\tlooking up expr {comp_id:?}"); let lexp = self.lookup_expression.lookup(comp_id)?; let handle = get_expr_handle!(comp_id, lexp); components.push(handle); @@ -3872,7 +3871,7 @@ impl> Frontend { ); block.push(crate::Statement::ControlBarrier(flags), span); } else { - log::warn!("Unsupported barrier execution scope: {}", exec_scope); + log::warn!("Unsupported barrier execution scope: {exec_scope}"); } } Op::MemoryBarrier => { @@ -4244,7 +4243,7 @@ impl> Frontend { let _memory_semantics_id = self.next()?; let span = self.span_from_with_op(start); - log::trace!("\t\t\tlooking up expr {:?}", pointer_id); + log::trace!("\t\t\tlooking up expr {pointer_id:?}"); let p_lexp_handle = get_expr_handle!(pointer_id, self.lookup_expression.lookup(pointer_id)?); @@ -4274,11 +4273,11 @@ impl> Frontend { let value_id = self.next()?; let span = self.span_from_with_op(start); - log::trace!("\t\t\tlooking up pointer expr {:?}", pointer_id); + log::trace!("\t\t\tlooking up pointer expr {pointer_id:?}"); let p_lexp_handle = get_expr_handle!(pointer_id, self.lookup_expression.lookup(pointer_id)?); - log::trace!("\t\t\tlooking up value expr {:?}", pointer_id); + log::trace!("\t\t\tlooking up value expr {pointer_id:?}"); let v_lexp_handle = get_expr_handle!(value_id, self.lookup_expression.lookup(value_id)?); @@ -4380,11 +4379,11 @@ impl> Frontend { body_idx, )?; - log::trace!("\t\t\tlooking up value expr {:?}", value_id); + log::trace!("\t\t\tlooking up value expr {value_id:?}"); let v_lexp_handle = get_expr_handle!(value_id, self.lookup_expression.lookup(value_id)?); - log::trace!("\t\t\tlooking up comparator expr {:?}", value_id); + log::trace!("\t\t\tlooking up comparator expr {value_id:?}"); let c_lexp_handle = get_expr_handle!( comparator_id, self.lookup_expression.lookup(comparator_id)? @@ -4699,7 +4698,7 @@ impl> Frontend { let generator = self.next()?; let _bound = self.next()?; let _schema = self.next()?; - log::info!("Generated by {} version {:x}", generator, version_raw); + log::info!("Generated by {generator} version {version_raw:x}"); crate::Module::default() }; @@ -4840,7 +4839,7 @@ impl> Frontend { if self.options.strict_capabilities { return Err(Error::UnsupportedCapability(cap)); } else { - log::warn!("Unknown capability {:?}", cap); + log::warn!("Unknown capability {cap:?}"); } } Ok(()) @@ -6030,7 +6029,7 @@ impl> Frontend { ) { Ok(handle) => Some(handle), Err(e) => { - log::warn!("Failed to initialize output built-in: {}", e); + log::warn!("Failed to initialize output built-in: {e}"); None } } @@ -6077,7 +6076,7 @@ impl> Frontend { let handle = module.global_variables.append(var, span); if module.types[ty].inner.can_comparison_sample(module) { - log::debug!("\t\ttracking {:?} for sampling properties", handle); + log::debug!("\t\ttracking {handle:?} for sampling properties"); self.handle_sampling .insert(handle, image::SamplingFlags::empty()); diff --git a/naga/src/front/wgsl/error.rs b/naga/src/front/wgsl/error.rs index 1123caff6..7f2c81812 100644 --- a/naga/src/front/wgsl/error.rs +++ b/naga/src/front/wgsl/error.rs @@ -690,7 +690,7 @@ impl<'a> Error<'a> { notes: vec![], }, Error::UnknownEnableExtension(span, word) => ParseError { - message: format!("unknown enable-extension `{}`", word), + message: format!("unknown enable-extension `{word}`"), labels: vec![(span, "".into())], notes: vec![ "See available extensions at ." @@ -1078,8 +1078,7 @@ impl<'a> Error<'a> { } = **error; ParseError { message: format!( - "automatic conversions cannot convert `{}` to `{}`", - source_type, dest_type + "automatic conversions cannot convert `{source_type}` to `{dest_type}`" ), labels: vec![ ( @@ -1103,15 +1102,13 @@ impl<'a> Error<'a> { } = **error; ParseError { message: format!( - "automatic conversions cannot convert elements of `{}` to `{}`", - source_type, dest_scalar + "automatic conversions cannot convert elements of `{source_type}` to `{dest_scalar}`" ), labels: vec![ ( dest_span, format!( - "a value with elements of type {} is required here", - dest_scalar + "a value with elements of type {dest_scalar} is required here" ) .into(), ), diff --git a/naga/src/front/wgsl/lower/mod.rs b/naga/src/front/wgsl/lower/mod.rs index 1f994d753..e60ae41a7 100644 --- a/naga/src/front/wgsl/lower/mod.rs +++ b/naga/src/front/wgsl/lower/mod.rs @@ -3400,12 +3400,12 @@ impl<'source, 'temp> Lowerer<'source, 'temp> { ir::TypeInner::Pointer { base, .. } => match ctx.module.types[base].inner { ir::TypeInner::Atomic(scalar) => Ok((pointer, scalar)), ref other => { - log::error!("Pointer type to {:?} passed to atomic op", other); + log::error!("Pointer type to {other:?} passed to atomic op"); Err(Box::new(Error::InvalidAtomicPointer(span))) } }, ref other => { - log::error!("Type {:?} passed to atomic op", other); + log::error!("Type {other:?} passed to atomic op"); Err(Box::new(Error::InvalidAtomicPointer(span))) } } @@ -4034,12 +4034,12 @@ impl<'source, 'temp> Lowerer<'source, 'temp> { ir::TypeInner::Pointer { base, .. } => match ctx.module.types[base].inner { ir::TypeInner::RayQuery { .. } => Ok(pointer), ref other => { - log::error!("Pointer type to {:?} passed to ray query op", other); + log::error!("Pointer type to {other:?} passed to ray query op"); Err(Box::new(Error::InvalidRayQueryPointer(span))) } }, ref other => { - log::error!("Type {:?} passed to ray query op", other); + log::error!("Type {other:?} passed to ray query op"); Err(Box::new(Error::InvalidRayQueryPointer(span))) } } diff --git a/naga/src/lib.rs b/naga/src/lib.rs index bdd5345c3..19b406588 100644 --- a/naga/src/lib.rs +++ b/naga/src/lib.rs @@ -75,7 +75,8 @@ void main() { clippy::derive_partial_eq_without_eq, clippy::needless_borrowed_reference, clippy::single_match, - clippy::enum_variant_names + clippy::enum_variant_names, + clippy::result_large_err )] #![warn( trivial_casts, diff --git a/naga/src/proc/constant_evaluator.rs b/naga/src/proc/constant_evaluator.rs index 4dba552f0..ac496f856 100644 --- a/naga/src/proc/constant_evaluator.rs +++ b/naga/src/proc/constant_evaluator.rs @@ -844,7 +844,7 @@ impl<'a> ConstantEvaluator<'a> { expr: &Expression, span: Span, ) -> Result, ConstantEvaluatorError> { - log::trace!("try_eval_and_append: {:?}", expr); + log::trace!("try_eval_and_append: {expr:?}"); match *expr { Expression::Constant(c) if self.is_global_arena() => { // "See through" the constant and use its initializer. @@ -2816,11 +2816,11 @@ fn first_leading_bit_smoke() { trait TryFromAbstract: Sized { /// Convert an abstract literal `value` to `Self`. /// - /// Since Naga's `AbstractInt` and `AbstractFloat` exist to support + /// Since Naga's [`AbstractInt`] and [`AbstractFloat`] exist to support /// WGSL, we follow WGSL's conversion rules here: /// /// - WGSL §6.1.2. Conversion Rank says that automatic conversions - /// from `AbstractInt` to an integer type are either lossless or an + /// from [`AbstractInt`] to an integer type are either lossless or an /// error. /// /// - WGSL §15.7.6 Floating Point Conversion says that conversions @@ -2834,7 +2834,7 @@ trait TryFromAbstract: Sized { /// conversion from AbstractFloat to integer types. /// /// [`AbstractInt`]: crate::Literal::AbstractInt - /// [`Float`]: crate::Literal::Float + /// [`AbstractFloat`]: crate::Literal::AbstractFloat fn try_from_abstract(value: T) -> Result; } diff --git a/naga/src/proc/index.rs b/naga/src/proc/index.rs index cf6a127ac..87eaac777 100644 --- a/naga/src/proc/index.rs +++ b/naga/src/proc/index.rs @@ -99,8 +99,8 @@ pub struct BoundsCheckPolicies { /// /// [`GlobalVariable`]: crate::GlobalVariable /// [`space`]: crate::GlobalVariable::space - /// [`Restrict`]: crate::back::BoundsCheckPolicy::Restrict - /// [`ReadZeroSkipWrite`]: crate::back::BoundsCheckPolicy::ReadZeroSkipWrite + /// [`Restrict`]: crate::proc::BoundsCheckPolicy::Restrict + /// [`ReadZeroSkipWrite`]: crate::proc::BoundsCheckPolicy::ReadZeroSkipWrite /// [`Access`]: crate::Expression::Access /// [`AccessIndex`]: crate::Expression::AccessIndex /// [`Storage`]: crate::AddressSpace::Storage diff --git a/naga/src/proc/overloads/regular.rs b/naga/src/proc/overloads/regular.rs index 3975592fa..0b180aa0e 100644 --- a/naga/src/proc/overloads/regular.rs +++ b/naga/src/proc/overloads/regular.rs @@ -195,7 +195,7 @@ fn make_rule( let inner = size.to_inner(scalar); let arg = TypeResolution::Value(inner.clone()); Rule { - arguments: core::iter::repeat(arg.clone()).take(arity).collect(), + arguments: core::iter::repeat_n(arg.clone(), arity).collect(), conclusion: conclusion_rule.conclude(size, scalar), } } diff --git a/naga/src/proc/typifier.rs b/naga/src/proc/typifier.rs index f7d1ea483..d675a898d 100644 --- a/naga/src/proc/typifier.rs +++ b/naga/src/proc/typifier.rs @@ -296,7 +296,7 @@ impl<'a> ResolveContext<'a> { }, Ti::BindingArray { base, .. } => Ti::Pointer { base, space }, ref other => { - log::error!("Access sub-type {:?}", other); + log::error!("Access sub-type {other:?}"); return Err(ResolveError::InvalidSubAccess { ty: base, indexed: false, @@ -306,7 +306,7 @@ impl<'a> ResolveContext<'a> { } Ti::BindingArray { base, .. } => TypeResolution::Handle(base), ref other => { - log::error!("Access type {:?}", other); + log::error!("Access type {other:?}"); return Err(ResolveError::InvalidAccess { expr: base, indexed: false, @@ -392,7 +392,7 @@ impl<'a> ResolveContext<'a> { } Ti::BindingArray { base, .. } => Ti::Pointer { base, space }, ref other => { - log::error!("Access index sub-type {:?}", other); + log::error!("Access index sub-type {other:?}"); return Err(ResolveError::InvalidSubAccess { ty: ty_base, indexed: true, @@ -401,7 +401,7 @@ impl<'a> ResolveContext<'a> { }), Ti::BindingArray { base, .. } => TypeResolution::Handle(base), ref other => { - log::error!("Access index type {:?}", other); + log::error!("Access index type {other:?}"); return Err(ResolveError::InvalidAccess { expr: base, indexed: true, @@ -412,7 +412,7 @@ impl<'a> ResolveContext<'a> { crate::Expression::Splat { size, value } => match *past(value)?.inner_with(types) { Ti::Scalar(scalar) => TypeResolution::Value(Ti::Vector { size, scalar }), ref other => { - log::error!("Scalar type {:?}", other); + log::error!("Scalar type {other:?}"); return Err(ResolveError::InvalidScalar(value)); } }, @@ -425,7 +425,7 @@ impl<'a> ResolveContext<'a> { TypeResolution::Value(Ti::Vector { size, scalar }) } ref other => { - log::error!("Vector type {:?}", other); + log::error!("Vector type {other:?}"); return Err(ResolveError::InvalidVector(vector)); } }, @@ -476,7 +476,7 @@ impl<'a> ResolveContext<'a> { None => Ti::Scalar(scalar), }), ref other => { - log::error!("Pointer type {:?}", other); + log::error!("Pointer type {other:?}"); return Err(ResolveError::InvalidPointer(pointer)); } }, @@ -496,7 +496,7 @@ impl<'a> ResolveContext<'a> { size: crate::VectorSize::Quad, }), ref other => { - log::error!("Image type {:?}", other); + log::error!("Image type {other:?}"); return Err(ResolveError::InvalidImage(image)); } }, @@ -514,7 +514,7 @@ impl<'a> ResolveContext<'a> { }, }), ref other => { - log::error!("Image type {:?}", other); + log::error!("Image type {other:?}"); return Err(ResolveError::InvalidImage(image)); } }, @@ -532,7 +532,7 @@ impl<'a> ResolveContext<'a> { }, }, ref other => { - log::error!("Image type {:?}", other); + log::error!("Image type {other:?}"); return Err(ResolveError::InvalidImage(image)); } }, diff --git a/naga/src/valid/compose.rs b/naga/src/valid/compose.rs index 20df99cbf..802ddb639 100644 --- a/naga/src/valid/compose.rs +++ b/naga/src/valid/compose.rs @@ -32,10 +32,7 @@ pub fn validate_compose( } if comp_scalar == scalar => comp_size as u32, ref other => { log::error!( - "Vector component[{}] type {:?}, building {:?}", - index, - other, - scalar + "Vector component[{index}] type {other:?}, building {scalar:?}" ); return Err(ComposeError::ComponentType { index: index as u32, @@ -65,7 +62,7 @@ pub fn validate_compose( } for (index, comp_res) in component_resolutions.enumerate() { if comp_res.inner_with(gctx.types) != &inner { - log::error!("Matrix component[{}] type {:?}", index, comp_res); + log::error!("Matrix component[{index}] type {comp_res:?}"); return Err(ComposeError::ComponentType { index: index as u32, }); @@ -85,7 +82,7 @@ pub fn validate_compose( } for (index, comp_res) in component_resolutions.enumerate() { if !gctx.compare_types(&TypeResolution::Handle(base), &comp_res) { - log::error!("Array component[{}] type {:?}", index, comp_res); + log::error!("Array component[{index}] type {comp_res:?}"); return Err(ComposeError::ComponentType { index: index as u32, }); @@ -102,7 +99,7 @@ pub fn validate_compose( for (index, (member, comp_res)) in members.iter().zip(component_resolutions).enumerate() { if !gctx.compare_types(&TypeResolution::Handle(member.ty), &comp_res) { - log::error!("Struct component[{}] type {:?}", index, comp_res); + log::error!("Struct component[{index}] type {comp_res:?}"); return Err(ComposeError::ComponentType { index: index as u32, }); @@ -110,7 +107,7 @@ pub fn validate_compose( } } ref other => { - log::error!("Composing of {:?}", other); + log::error!("Composing of {other:?}"); return Err(ComposeError::Type(self_ty_handle)); } } diff --git a/naga/src/valid/expression.rs b/naga/src/valid/expression.rs index 8b73486b1..a2675d8c7 100644 --- a/naga/src/valid/expression.rs +++ b/naga/src/valid/expression.rs @@ -266,7 +266,7 @@ impl super::Validator { | Ti::ValuePointer { size: Some(_), .. } | Ti::BindingArray { .. } => {} ref other => { - log::error!("Indexing of {:?}", other); + log::error!("Indexing of {other:?}"); return Err(ExpressionError::InvalidBaseType(base)); } }; @@ -277,7 +277,7 @@ impl super::Validator { .. }) => {} ref other => { - log::error!("Indexing by {:?}", other); + log::error!("Indexing by {other:?}"); return Err(ExpressionError::InvalidIndexType(index)); } } @@ -332,7 +332,7 @@ impl super::Validator { } Ti::Struct { ref members, .. } => members.len() as u32, ref other => { - log::error!("Indexing of {:?}", other); + log::error!("Indexing of {other:?}"); return Err(ExpressionError::InvalidBaseType(top)); } }; @@ -348,7 +348,7 @@ impl super::Validator { E::Splat { size: _, value } => match resolver[value] { Ti::Scalar { .. } => ShaderStages::all(), ref other => { - log::error!("Splat scalar type {:?}", other); + log::error!("Splat scalar type {other:?}"); return Err(ExpressionError::InvalidSplatType(value)); } }, @@ -360,7 +360,7 @@ impl super::Validator { let vec_size = match resolver[vector] { Ti::Vector { size: vec_size, .. } => vec_size, ref other => { - log::error!("Swizzle vector type {:?}", other); + log::error!("Swizzle vector type {other:?}"); return Err(ExpressionError::InvalidVectorType(vector)); } }; @@ -400,7 +400,7 @@ impl super::Validator { .contains(TypeFlags::SIZED | TypeFlags::DATA) => {} Ti::ValuePointer { .. } => {} ref other => { - log::error!("Loading {:?}", other); + log::error!("Loading {other:?}"); return Err(ExpressionError::InvalidPointerType(pointer)); } } @@ -766,7 +766,7 @@ impl super::Validator { | (Uo::LogicalNot, Some(Sk::Bool)) | (Uo::BitwiseNot, Some(Sk::Sint | Sk::Uint)) => {} other => { - log::error!("Op {:?} kind {:?}", op, other); + log::error!("Op {op:?} kind {other:?}"); return Err(ExpressionError::InvalidUnaryOperandType(op, expr)); } } @@ -875,7 +875,7 @@ impl super::Validator { Sk::Bool | Sk::AbstractInt | Sk::AbstractFloat => false, }, ref other => { - log::error!("Op {:?} left type {:?}", op, other); + log::error!("Op {op:?} left type {other:?}"); false } } @@ -887,7 +887,7 @@ impl super::Validator { .. } => left_inner == right_inner, ref other => { - log::error!("Op {:?} left type {:?}", op, other); + log::error!("Op {op:?} left type {other:?}"); false } }, @@ -897,7 +897,7 @@ impl super::Validator { Sk::Float | Sk::AbstractInt | Sk::AbstractFloat => false, }, ref other => { - log::error!("Op {:?} left type {:?}", op, other); + log::error!("Op {op:?} left type {other:?}"); false } }, @@ -907,7 +907,7 @@ impl super::Validator { Sk::Bool | Sk::Float | Sk::AbstractInt | Sk::AbstractFloat => false, }, ref other => { - log::error!("Op {:?} left type {:?}", op, other); + log::error!("Op {op:?} left type {other:?}"); false } }, @@ -916,7 +916,7 @@ impl super::Validator { Ti::Scalar(scalar) => (Ok(None), scalar), Ti::Vector { size, scalar } => (Ok(Some(size)), scalar), ref other => { - log::error!("Op {:?} base type {:?}", op, other); + log::error!("Op {op:?} base type {other:?}"); (Err(()), Sc::BOOL) } }; @@ -927,7 +927,7 @@ impl super::Validator { scalar: Sc { kind: Sk::Uint, .. }, } => Ok(Some(size)), ref other => { - log::error!("Op {:?} shift type {:?}", op, other); + log::error!("Op {op:?} shift type {other:?}"); Err(()) } }; @@ -1032,7 +1032,7 @@ impl super::Validator { .. } => {} ref other => { - log::error!("All/Any of type {:?}", other); + log::error!("All/Any of type {other:?}"); return Err(ExpressionError::InvalidBooleanVector(argument)); } }, @@ -1040,7 +1040,7 @@ impl super::Validator { Ti::Scalar(scalar) | Ti::Vector { scalar, .. } if scalar.kind == Sk::Float => {} ref other => { - log::error!("Float test of type {:?}", other); + log::error!("Float test of type {other:?}"); return Err(ExpressionError::InvalidFloatArgument(argument)); } }, @@ -1164,7 +1164,7 @@ impl super::Validator { } } ref other => { - log::error!("Array length of {:?}", other); + log::error!("Array length of {other:?}"); return Err(ExpressionError::InvalidArrayType(expr)); } }, @@ -1179,12 +1179,12 @@ impl super::Validator { } => match resolver.types[base].inner { Ti::RayQuery { .. } => ShaderStages::all(), ref other => { - log::error!("Intersection result of a pointer to {:?}", other); + log::error!("Intersection result of a pointer to {other:?}"); return Err(ExpressionError::InvalidRayQueryType(query)); } }, ref other => { - log::error!("Intersection result of {:?}", other); + log::error!("Intersection result of {other:?}"); return Err(ExpressionError::InvalidRayQueryType(query)); } }, @@ -1200,12 +1200,12 @@ impl super::Validator { vertex_return: true, } => ShaderStages::all(), ref other => { - log::error!("Intersection result of a pointer to {:?}", other); + log::error!("Intersection result of a pointer to {other:?}"); return Err(ExpressionError::InvalidRayQueryType(query)); } }, ref other => { - log::error!("Intersection result of {:?}", other); + log::error!("Intersection result of {other:?}"); return Err(ExpressionError::InvalidRayQueryType(query)); } }, diff --git a/naga/src/valid/function.rs b/naga/src/valid/function.rs index fb88f3934..dc19e1917 100644 --- a/naga/src/valid/function.rs +++ b/naga/src/valid/function.rs @@ -509,7 +509,7 @@ impl super::Validator { | crate::AtomicFunction::Subtract | crate::AtomicFunction::Exchange { compare: None } ) { - log::error!("Float32 atomic operation {:?} is not supported", fun); + log::error!("Float32 atomic operation {fun:?} is not supported"); return Err(AtomicError::InvalidOperator(*fun) .with_span_handle(value, context.expressions) .into_other()); @@ -639,7 +639,7 @@ impl super::Validator { crate::TypeInner::Scalar(scalar) => (true, scalar), crate::TypeInner::Vector { scalar, .. } => (false, scalar), _ => { - log::error!("Subgroup operand type {:?}", argument_inner); + log::error!("Subgroup operand type {argument_inner:?}"); return Err(SubgroupError::InvalidOperand(argument) .with_span_handle(argument, context.expressions) .into_other()); @@ -654,7 +654,7 @@ impl super::Validator { (sk::Sint | sk::Uint, sg::And | sg::Or | sg::Xor) => {} (_, _) => { - log::error!("Subgroup operand type {:?}", argument_inner); + log::error!("Subgroup operand type {argument_inner:?}"); return Err(SubgroupError::InvalidOperand(argument) .with_span_handle(argument, context.expressions) .into_other()); @@ -714,8 +714,7 @@ impl super::Validator { crate::TypeInner::Scalar(crate::Scalar::U32) => {} _ => { log::error!( - "Subgroup gather index type {:?}, expected unsigned int", - index_ty + "Subgroup gather index type {index_ty:?}, expected unsigned int" ); return Err(SubgroupError::InvalidOperand(argument) .with_span_handle(index, context.expressions) @@ -740,7 +739,7 @@ impl super::Validator { crate::TypeInner::Scalar ( scalar, .. ) | crate::TypeInner::Vector { scalar, .. } if matches!(scalar.kind, crate::ScalarKind::Uint | crate::ScalarKind::Sint | crate::ScalarKind::Float) ) { - log::error!("Subgroup gather operand type {:?}", argument_inner); + log::error!("Subgroup gather operand type {argument_inner:?}"); return Err(SubgroupError::InvalidOperand(argument) .with_span_handle(argument, context.expressions) .into_other()); @@ -1567,8 +1566,7 @@ impl super::Validator { crate::TypeInner::Scalar(crate::Scalar::BOOL,) ) { log::error!( - "Subgroup ballot predicate type {:?} expected bool", - predicate_inner + "Subgroup ballot predicate type {predicate_inner:?} expected bool" ); return Err(SubgroupError::InvalidOperand(predicate) .with_span_handle(predicate, context.expressions) @@ -1645,7 +1643,7 @@ impl super::Validator { fun_info: &FunctionInfo, local_expr_kind: &crate::proc::ExpressionKindTracker, ) -> Result<(), LocalVariableError> { - log::debug!("var {:?}", var); + log::debug!("var {var:?}"); let type_info = self .types .get(var.ty.index()) diff --git a/naga/src/valid/interface.rs b/naga/src/valid/interface.rs index 14cfa42e8..7c8cc9031 100644 --- a/naga/src/valid/interface.rs +++ b/naga/src/valid/interface.rs @@ -309,7 +309,7 @@ impl VaryingContext<'_> { return Err(VaryingError::InvalidBuiltInStage(built_in)); } if !type_good { - log::warn!("Wrong builtin type: {:?}", ty_inner); + log::warn!("Wrong builtin type: {ty_inner:?}"); return Err(VaryingError::InvalidBuiltInType(built_in)); } } @@ -501,7 +501,7 @@ impl super::Validator { ) -> Result<(), GlobalVariableError> { use super::TypeFlags; - log::debug!("var {:?}", var); + log::debug!("var {var:?}"); let inner_ty = match gctx.types[var.ty].inner { // A binding array is (mostly) supposed to behave the same as a // series of individually bound resources, so we can (mostly) @@ -795,12 +795,8 @@ impl super::Validator { crate::AddressSpace::PushConstant => GlobalUse::READ, }; if !allowed_usage.contains(usage) { - log::warn!("\tUsage error for: {:?}", var); - log::warn!( - "\tAllowed usage: {:?}, requested: {:?}", - allowed_usage, - usage - ); + log::warn!("\tUsage error for: {var:?}"); + log::warn!("\tAllowed usage: {allowed_usage:?}, requested: {usage:?}"); return Err(EntryPointError::InvalidGlobalUsage(var_handle, usage) .with_span_handle(var_handle, &module.global_variables)); } diff --git a/naga/tests/naga/snapshots.rs b/naga/tests/naga/snapshots.rs index 32e2f5e02..e6e848deb 100644 --- a/naga/tests/naga/snapshots.rs +++ b/naga/tests/naga/snapshots.rs @@ -357,7 +357,7 @@ impl Input { "spvasm" => params.targets = Some(Targets::non_wgsl_default()), "vert" | "frag" | "comp" => params.targets = Some(Targets::non_wgsl_default()), e => { - panic!("Unknown extension: {}", e); + panic!("Unknown extension: {e}"); } } } diff --git a/naga/tests/naga/validation.rs b/naga/tests/naga/validation.rs index b7ba70ee0..9da549f8f 100644 --- a/naga/tests/naga/validation.rs +++ b/naga/tests/naga/validation.rs @@ -1,3 +1,8 @@ +#![allow( + // We need to investiagate these. + clippy::result_large_err +)] + use naga::{ ir, valid::{self, ModuleInfo}, diff --git a/naga/tests/naga/wgsl_errors.rs b/naga/tests/naga/wgsl_errors.rs index 962c8f46a..5784192ef 100644 --- a/naga/tests/naga/wgsl_errors.rs +++ b/naga/tests/naga/wgsl_errors.rs @@ -2,6 +2,10 @@ Tests for the WGSL front end. */ #![cfg(feature = "wgsl-in")] +#![allow( + // We need to investiagate these. + clippy::result_large_err +)] use naga::{compact::KeepUnused, valid::Capabilities}; diff --git a/naga/xtask/Cargo.toml b/naga/xtask/Cargo.toml index a56a07515..8b921bc31 100644 --- a/naga/xtask/Cargo.toml +++ b/naga/xtask/Cargo.toml @@ -3,7 +3,7 @@ name = "naga-xtask" version = "0.1.0" edition = "2021" publish = false -rust-version = "1.84" +rust-version.workspace = true [target.'cfg(not(target_arch = "wasm32"))'.dependencies] anyhow.workspace = true diff --git a/naga/xtask/src/validate.rs b/naga/xtask/src/validate.rs index d1d75783e..661440067 100644 --- a/naga/xtask/src/validate.rs +++ b/naga/xtask/src/validate.rs @@ -46,7 +46,7 @@ pub(crate) fn validate(cmd: ValidateSubcommand) -> anyhow::Result<()> { if let Err(error) = result { all_good = false; progress_bar.suspend(|| { - log::error!("{:#}", error); + log::error!("{error:#}"); }); } progress_bar.inc(1); diff --git a/player/src/bin/play.rs b/player/src/bin/play.rs index 719a5c096..5d908a3a0 100644 --- a/player/src/bin/play.rs +++ b/player/src/bin/play.rs @@ -33,7 +33,7 @@ fn main() { _ => panic!("Provide the dir path as the parameter"), }; - log::info!("Loading trace '{:?}'", dir); + log::info!("Loading trace '{dir:?}'"); let file = fs::File::open(dir.join(trace::FILE_NAME)).unwrap(); let mut actions: Vec = ron::de::from_reader(file).unwrap(); actions.reverse(); // allows us to pop from the top @@ -66,7 +66,7 @@ fn main() { let (device, queue) = match actions.pop() { Some(trace::Action::Init { desc, backend }) => { - log::info!("Initializing the device for backend: {:?}", backend); + log::info!("Initializing the device for backend: {backend:?}"); let adapter = global .request_adapter( &wgc::instance::RequestAdapterOptions { @@ -143,18 +143,18 @@ fn main() { let error = global.surface_configure(surface, device, &config); if let Some(e) = error { - panic!("{:?}", e); + panic!("{e:?}"); } } } Some(trace::Action::Present(id)) => { frame_count += 1; - log::debug!("Presenting frame {}", frame_count); + log::debug!("Presenting frame {frame_count}"); global.surface_present(id).unwrap(); target.exit(); } Some(trace::Action::DiscardSurfaceTexture(id)) => { - log::debug!("Discarding frame {}", frame_count); + log::debug!("Discarding frame {frame_count}"); global.surface_texture_discard(id).unwrap(); target.exit(); } @@ -169,7 +169,7 @@ fn main() { } None => { if !done { - println!("Finished the end at frame {}", frame_count); + println!("Finished the end at frame {frame_count}"); done = true; } target.exit(); @@ -180,7 +180,7 @@ fn main() { if let Some(config) = resize_config.take() { let error = global.surface_configure(surface, device, &config); if let Some(e) = error { - panic!("{:?}", e); + panic!("{e:?}"); } } } diff --git a/player/src/lib.rs b/player/src/lib.rs index 16e319471..90f3fd882 100644 --- a/player/src/lib.rs +++ b/player/src/lib.rs @@ -189,7 +189,7 @@ impl GlobalPlay for wgc::global::Global { comb_manager: &mut wgc::identity::IdentityManager, ) { use wgc::device::trace::Action; - log::debug!("action {:?}", action); + log::debug!("action {action:?}"); //TODO: find a way to force ID perishing without excessive `maintain()` calls. match action { Action::Init { .. } => { @@ -280,7 +280,7 @@ impl GlobalPlay for wgc::global::Global { self.bind_group_drop(id); } Action::CreateShaderModule { id, desc, data } => { - log::debug!("Creating shader from {}", data); + log::debug!("Creating shader from {data}"); let code = fs::read_to_string(dir.join(&data)).unwrap(); let source = if data.ends_with(".wgsl") { wgc::pipeline::ShaderModuleSource::Wgsl(Cow::Owned(code.clone())) diff --git a/rust-toolchain.toml b/rust-toolchain.toml index 1ed8cd0e6..607c42c96 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,4 +1,4 @@ [toolchain] -channel = "1.84" +channel = "1.88" components = ["rustfmt", "clippy"] targets = ["wasm32-unknown-unknown"] diff --git a/tests/src/isolation.rs b/tests/src/isolation.rs index d99f42508..75d98c115 100644 --- a/tests/src/isolation.rs +++ b/tests/src/isolation.rs @@ -31,7 +31,7 @@ impl OneTestPerProcessGuard { // We never abort if we're on wasm. Wasm tests are inherently single threaded, and panics cannot // unwind the stack and trigger all the guards, so we don't actually need to check. if other_tests_in_flight && !cfg!(target_arch = "wasm32") { - log::error!("{}", OTHER_TEST_IN_PROGRESS_ERROR); + log::error!("{OTHER_TEST_IN_PROGRESS_ERROR}"); // Hard exit to call attention to the error std::process::abort(); } diff --git a/tests/tests/wgpu-gpu/buffer_usages.rs b/tests/tests/wgpu-gpu/buffer_usages.rs index efb7636f6..4c5312e12 100644 --- a/tests/tests/wgpu-gpu/buffer_usages.rs +++ b/tests/tests/wgpu-gpu/buffer_usages.rs @@ -83,7 +83,7 @@ async fn map_test( after_unmap: bool, after_destroy: bool, ) { - log::info!("map_test usage_type:{usage_type} map_mode_type:{:?} before_unmap:{before_unmap} before_destroy:{before_destroy} after_unmap:{after_unmap} after_destroy:{after_destroy}", map_mode_type); + log::info!("map_test usage_type:{usage_type} map_mode_type:{map_mode_type:?} before_unmap:{before_unmap} before_destroy:{before_destroy} after_unmap:{after_unmap} after_destroy:{after_destroy}"); let size = 8; let usage = match usage_type { diff --git a/tests/tests/wgpu-gpu/clear_texture.rs b/tests/tests/wgpu-gpu/clear_texture.rs index 0789eedb1..23883b241 100644 --- a/tests/tests/wgpu-gpu/clear_texture.rs +++ b/tests/tests/wgpu-gpu/clear_texture.rs @@ -209,12 +209,7 @@ async fn single_texture_clear_test( size: wgpu::Extent3d, dimension: wgpu::TextureDimension, ) { - log::info!( - "clearing texture with {:?}, dimension {:?}, size {:?}", - format, - dimension, - size - ); + log::info!("clearing texture with {format:?}, dimension {dimension:?}, size {size:?}"); let extra_usages = match format { wgpu::TextureFormat::Depth24Plus | wgpu::TextureFormat::Depth24PlusStencil8 => { diff --git a/tests/tests/wgpu-gpu/samplers.rs b/tests/tests/wgpu-gpu/samplers.rs index 97e57a55f..adb49d067 100644 --- a/tests/tests/wgpu-gpu/samplers.rs +++ b/tests/tests/wgpu-gpu/samplers.rs @@ -114,7 +114,7 @@ fn sampler_creation_failure(ctx: TestingContext) { for i in 0..failed_count { valid(&ctx.device, || { - eprintln!("Trying to create sampler {}", i); + eprintln!("Trying to create sampler {i}"); let sampler = ctx.device.create_sampler(&wgpu::SamplerDescriptor { lod_min_clamp: i as f32 * 0.01, // Change the max clamp to ensure the sampler is using different cache slots from @@ -188,7 +188,7 @@ fn sampler_bind_group(ctx: TestingContext, group_type: GroupType) { GroupType::Multi => MULTI_GROUP_BINDINGS, }; - let full_shader = format!("{}\n{}", bindings, SAMPLER_CODE); + let full_shader = format!("{bindings}\n{SAMPLER_CODE}"); let module = ctx .device diff --git a/tests/tests/wgpu-gpu/timestamp_normalization/utils.rs b/tests/tests/wgpu-gpu/timestamp_normalization/utils.rs index aaf0548fa..b68e2e0f6 100644 --- a/tests/tests/wgpu-gpu/timestamp_normalization/utils.rs +++ b/tests/tests/wgpu-gpu/timestamp_normalization/utils.rs @@ -51,8 +51,7 @@ fn assert_u64_mul_u32(left: u64, right: u32, computed: Uint96) { assert_eq!( computed, real, - "{left} * {right} should be {real} but is {}", - computed + "{left} * {right} should be {real} but is {computed}" ); } diff --git a/wgpu-core/src/device/global.rs b/wgpu-core/src/device/global.rs index cf2412536..92d0ea54b 100644 --- a/wgpu-core/src/device/global.rs +++ b/wgpu-core/src/device/global.rs @@ -1833,7 +1833,7 @@ impl Global { Ok(()) } - log::debug!("configuring surface with {:?}", config); + log::debug!("configuring surface with {config:?}"); let error = 'error: { // User callbacks must not be called while we are holding locks. @@ -1968,7 +1968,7 @@ impl Global { E::Device(device.handle_hal_error(error)) } hal::SurfaceError::Other(message) => { - log::error!("surface configuration failed: {}", message); + log::error!("surface configuration failed: {message}"); E::InvalidSurface } } diff --git a/wgpu-core/src/device/life.rs b/wgpu-core/src/device/life.rs index 67bb8a3c6..ed8b3862a 100644 --- a/wgpu-core/src/device/life.rs +++ b/wgpu-core/src/device/life.rs @@ -22,7 +22,6 @@ use crate::{ /// resources it uses must remain alive until it has finished executing. /// /// [`wgpu_hal`]: hal -/// [`ResourceInfo::submission_index`]: crate::resource::ResourceInfo struct ActiveSubmission { /// The index of the submission we track. /// diff --git a/wgpu-core/src/device/resource.rs b/wgpu-core/src/device/resource.rs index 4b41ff8b8..3e38726b8 100644 --- a/wgpu-core/src/device/resource.rs +++ b/wgpu-core/src/device/resource.rs @@ -553,9 +553,7 @@ impl Device { // This is defensive, as this should never be hit. assert!( current_finished_submission >= wait_submission_index, - "If the queue is empty, the current submission index ({}) should be at least the wait submission index ({})", - current_finished_submission, - wait_submission_index + "If the queue is empty, the current submission index ({current_finished_submission}) should be at least the wait submission index ({wait_submission_index})" ); } @@ -1772,7 +1770,7 @@ impl Device { pipeline::CreateShaderModuleError::Device(self.handle_hal_error(error)) } hal::ShaderError::Compilation(ref msg) => { - log::error!("Shader error: {}", msg); + log::error!("Shader error: {msg}"); pipeline::CreateShaderModuleError::Generation } }) @@ -1841,7 +1839,7 @@ impl Device { pipeline::CreateShaderModuleError::Device(self.handle_hal_error(error)) } hal::ShaderError::Compilation(ref msg) => { - log::error!("Shader error: {}", msg); + log::error!("Shader error: {msg}"); pipeline::CreateShaderModuleError::Generation } }) diff --git a/wgpu-core/src/device/trace.rs b/wgpu-core/src/device/trace.rs index 9d031bef8..33025818f 100644 --- a/wgpu-core/src/device/trace.rs +++ b/wgpu-core/src/device/trace.rs @@ -220,7 +220,7 @@ pub struct Trace { #[cfg(feature = "trace")] impl Trace { pub fn new(path: std::path::PathBuf) -> Result { - log::info!("Tracing into '{:?}'", path); + log::info!("Tracing into '{path:?}'"); let mut file = std::fs::File::create(path.join(FILE_NAME))?; file.write_all(b"[\n")?; Ok(Self { @@ -241,10 +241,10 @@ impl Trace { pub(crate) fn add(&mut self, action: Action) { match ron::ser::to_string_pretty(&action, self.config.clone()) { Ok(string) => { - let _ = writeln!(self.file, "{},", string); + let _ = writeln!(self.file, "{string},"); } Err(e) => { - log::warn!("RON serialization failure: {:?}", e); + log::warn!("RON serialization failure: {e:?}"); } } } diff --git a/wgpu-core/src/id.rs b/wgpu-core/src/id.rs index 8858e1f89..cac9c1348 100644 --- a/wgpu-core/src/id.rs +++ b/wgpu-core/src/id.rs @@ -75,7 +75,7 @@ impl RawId { /// [`Hub`]: crate::hub::Hub /// [`Hub`]: crate::hub::Hub /// [`Texture`]: crate::resource::Texture -/// [`Registry`]: crate::hub::Registry +/// [`Registry`]: crate::registry::Registry /// [`Noop`]: hal::api::Noop #[repr(transparent)] #[cfg_attr(any(feature = "serde", feature = "trace"), derive(serde::Serialize))] diff --git a/wgpu-core/src/identity.rs b/wgpu-core/src/identity.rs index 0870b905e..b34282207 100644 --- a/wgpu-core/src/identity.rs +++ b/wgpu-core/src/identity.rs @@ -33,7 +33,6 @@ enum IdSource { /// ids with new index values. Freed vector entries get reused. /// /// [`Id`]: crate::id::Id -/// [`Backend`]: wgt::Backend; /// [`alloc`]: IdentityValues::alloc /// [`release`]: IdentityValues::release #[derive(Debug)] diff --git a/wgpu-core/src/indirect_validation/dispatch.rs b/wgpu-core/src/indirect_validation/dispatch.rs index a1c1627fd..04a283eb4 100644 --- a/wgpu-core/src/indirect_validation/dispatch.rs +++ b/wgpu-core/src/indirect_validation/dispatch.rs @@ -124,7 +124,7 @@ impl Dispatch { CreateShaderModuleError::Device(DeviceError::from_hal(error)) } hal::ShaderError::Compilation(ref msg) => { - log::error!("Shader error: {}", msg); + log::error!("Shader error: {msg}"); CreateShaderModuleError::Generation } } diff --git a/wgpu-core/src/indirect_validation/draw.rs b/wgpu-core/src/indirect_validation/draw.rs index 8e6943f3c..bc26eb717 100644 --- a/wgpu-core/src/indirect_validation/draw.rs +++ b/wgpu-core/src/indirect_validation/draw.rs @@ -509,7 +509,7 @@ fn create_validation_module( CreateShaderModuleError::Device(DeviceError::from_hal(error)) } hal::ShaderError::Compilation(ref msg) => { - log::error!("Shader error: {}", msg); + log::error!("Shader error: {msg}"); CreateShaderModuleError::Generation } }, diff --git a/wgpu-core/src/instance.rs b/wgpu-core/src/instance.rs index 4f36b0a85..cf7629e40 100644 --- a/wgpu-core/src/instance.rs +++ b/wgpu-core/src/instance.rs @@ -220,9 +220,7 @@ impl Instance { } Err(err) => { log::debug!( - "Instance::create_surface: failed to create surface for {:?}: {:?}", - backend, - err + "Instance::create_surface: failed to create surface for {backend:?}: {err:?}" ); errors.insert(*backend, err); } @@ -415,7 +413,7 @@ impl Instance { { // NOTE: We might be using `profiling` without any features. The empty backend of this // macro emits no code, so unused code linting changes depending on the backend. - profiling::scope!("enumerating", &*alloc::format!("{:?}", _backend)); + profiling::scope!("enumerating", &*alloc::format!("{_backend:?}")); let hal_adapters = unsafe { instance.enumerate_adapters(None) }; for raw in hal_adapters { @@ -452,7 +450,7 @@ impl Instance { let mut backend_adapters = unsafe { instance.enumerate_adapters(compatible_hal_surface) }; if backend_adapters.is_empty() { - log::debug!("enabled backend `{:?}` has no adapters", backend); + log::debug!("enabled backend `{backend:?}` has no adapters"); no_adapter_backends |= Backends::from(backend); // by continuing, we avoid setting the further error bits below continue; @@ -468,7 +466,7 @@ impl Instance { keep }); if backend_adapters.is_empty() { - log::debug!("* Backend `{:?}` has no fallback adapters", backend); + log::debug!("* Backend `{backend:?}` has no fallback adapters"); no_fallback_backends |= Backends::from(backend); continue; } @@ -804,11 +802,7 @@ impl Adapter { && !caps.downlevel.is_webgpu_compliant() { let missing_flags = wgt::DownlevelFlags::compliant() - caps.downlevel.flags; - log::warn!( - "Missing downlevel flags: {:?}\n{}", - missing_flags, - DOWNLEVEL_WARNING_MESSAGE - ); + log::warn!("Missing downlevel flags: {missing_flags:?}\n{DOWNLEVEL_WARNING_MESSAGE}"); log::warn!("{:#?}", caps.downlevel); } diff --git a/wgpu-core/src/lib.rs b/wgpu-core/src/lib.rs index 54c9f1cdc..a22e218d4 100644 --- a/wgpu-core/src/lib.rs +++ b/wgpu-core/src/lib.rs @@ -36,7 +36,9 @@ // It gets in the way a lot and does not prevent bugs in practice. clippy::pattern_type_mismatch, // `wgpu-core` isn't entirely user-facing, so it's useful to document internal items. - rustdoc::private_intra_doc_links + rustdoc::private_intra_doc_links, + // We should investigate these. + clippy::result_large_err )] #![warn( clippy::alloc_instead_of_core, diff --git a/wgpu-core/src/lock/observing.rs b/wgpu-core/src/lock/observing.rs index 16ae51be4..f3f61455d 100644 --- a/wgpu-core/src/lock/observing.rs +++ b/wgpu-core/src/lock/observing.rs @@ -294,13 +294,10 @@ fn acquire(new_rank: LockRank, location: &'static Location<'static>) -> Option Status::Outdated, hal::SurfaceError::Other(msg) => { - log::error!("acquire error: {}", msg); + log::error!("acquire error: {msg}"); Status::Lost } }, @@ -309,7 +309,7 @@ impl Surface { } hal::SurfaceError::Outdated => Ok(Status::Outdated), hal::SurfaceError::Other(msg) => { - log::error!("acquire error: {}", msg); + log::error!("acquire error: {msg}"); Err(SurfaceError::Invalid) } }, diff --git a/wgpu-core/src/timestamp_normalization/mod.rs b/wgpu-core/src/timestamp_normalization/mod.rs index e5a9ef9a8..651773c38 100644 --- a/wgpu-core/src/timestamp_normalization/mod.rs +++ b/wgpu-core/src/timestamp_normalization/mod.rs @@ -177,7 +177,7 @@ impl TimestampNormalizer { CreateShaderModuleError::Device(device.handle_hal_error(error)) } hal::ShaderError::Compilation(ref msg) => { - log::error!("Shader error: {}", msg); + log::error!("Shader error: {msg}"); CreateShaderModuleError::Generation } })?; @@ -274,8 +274,7 @@ impl TimestampNormalizer { let bg_label_alloc; let label = match buffer_label { Some(label) => { - bg_label_alloc = - alloc::format!("Timestamp normalization bind group ({})", label); + bg_label_alloc = alloc::format!("Timestamp normalization bind group ({label})"); &*bg_label_alloc } None => "Timestamp normalization bind group", diff --git a/wgpu-core/src/validation.rs b/wgpu-core/src/validation.rs index fe303ace7..f720ef68b 100644 --- a/wgpu-core/src/validation.rs +++ b/wgpu-core/src/validation.rs @@ -937,7 +937,7 @@ impl Interface { // the reality is - every shader coming from `glslc` outputs an array // of clip distances and hits this path :( // So we lower it to `log::warn` to be less annoying. - log::warn!("Unexpected varying type: {:?}", other); + log::warn!("Unexpected varying type: {other:?}"); return; } }; diff --git a/wgpu-hal/examples/halmark/main.rs b/wgpu-hal/examples/halmark/main.rs index 153bd49ad..8f93cc586 100644 --- a/wgpu-hal/examples/halmark/main.rs +++ b/wgpu-hal/examples/halmark/main.rs @@ -123,7 +123,7 @@ impl Example { let surface_caps = unsafe { adapter.surface_capabilities(&surface) } .ok_or("failed to get surface capabilities")?; - log::info!("Surface caps: {:#?}", surface_caps); + log::info!("Surface caps: {surface_caps:#?}"); let hal::OpenDevice { device, queue } = unsafe { adapter diff --git a/wgpu-hal/examples/ray-traced-triangle/main.rs b/wgpu-hal/examples/ray-traced-triangle/main.rs index 93e687ff1..4fcb66913 100644 --- a/wgpu-hal/examples/ray-traced-triangle/main.rs +++ b/wgpu-hal/examples/ray-traced-triangle/main.rs @@ -269,7 +269,7 @@ impl Example { }; let surface_caps = unsafe { adapter.surface_capabilities(&surface) } .expect("Surface doesn't support presentation"); - log::info!("Surface caps: {:#?}", surface_caps); + log::info!("Surface caps: {surface_caps:#?}"); let hal::OpenDevice { device, queue } = unsafe { adapter diff --git a/wgpu-hal/src/auxil/dxgi/exception.rs b/wgpu-hal/src/auxil/dxgi/exception.rs index b938da31f..e520ab185 100644 --- a/wgpu-hal/src/auxil/dxgi/exception.rs +++ b/wgpu-hal/src/auxil/dxgi/exception.rs @@ -80,7 +80,7 @@ unsafe extern "system" fn output_debug_string_handler( } let _ = std::panic::catch_unwind(|| { - log::log!(level, "{}", message); + log::log!(level, "{message}"); }); #[cfg(feature = "validation_canary")] diff --git a/wgpu-hal/src/auxil/dxgi/factory.rs b/wgpu-hal/src/auxil/dxgi/factory.rs index dd7305c1b..ac050bcd3 100644 --- a/wgpu-hal/src/auxil/dxgi/factory.rs +++ b/wgpu-hal/src/auxil/dxgi/factory.rs @@ -89,7 +89,7 @@ pub fn enumerate_adapters(factory: DxgiFactory) -> Vec { Ok(a) => a, Err(e) if e.code() == Dxgi::DXGI_ERROR_NOT_FOUND => break, Err(e) => { - log::error!("Failed enumerating adapters: {}", e); + log::error!("Failed enumerating adapters: {e}"); break; } }; diff --git a/wgpu-hal/src/auxil/dxgi/result.rs b/wgpu-hal/src/auxil/dxgi/result.rs index 23e1e0bea..256e08278 100644 --- a/wgpu-hal/src/auxil/dxgi/result.rs +++ b/wgpu-hal/src/auxil/dxgi/result.rs @@ -8,7 +8,7 @@ impl HResult for windows::core::Result { #![allow(unreachable_code)] self.map_err(|err| { - log::error!("{} failed: {}", description, err); + log::error!("{description} failed: {err}"); match err.code() { Foundation::E_OUTOFMEMORY => crate::DeviceError::OutOfMemory, diff --git a/wgpu-hal/src/auxil/renderdoc.rs b/wgpu-hal/src/auxil/renderdoc.rs index 2770869be..52fa2b0bd 100644 --- a/wgpu-hal/src/auxil/renderdoc.rs +++ b/wgpu-hal/src/auxil/renderdoc.rs @@ -77,8 +77,7 @@ impl RenderDoc { Err(e) => { return RenderDoc::NotAvailable { reason: format!( - "Unable to get RENDERDOC_GetAPI from renderdoc library '{}': {e:?}", - renderdoc_filename + "Unable to get RENDERDOC_GetAPI from renderdoc library '{renderdoc_filename}': {e:?}" ), } } @@ -93,8 +92,7 @@ impl RenderDoc { }, return_value => RenderDoc::NotAvailable { reason: format!( - "Unable to get API from renderdoc library '{}': {}", - renderdoc_filename, return_value + "Unable to get API from renderdoc library '{renderdoc_filename}': {return_value}" ), }, } @@ -123,7 +121,7 @@ impl RenderDoc { true } Self::NotAvailable { ref reason } => { - log::warn!("Could not start RenderDoc frame capture: {}", reason); + log::warn!("Could not start RenderDoc frame capture: {reason}"); false } } @@ -136,7 +134,7 @@ impl RenderDoc { unsafe { entry.api.EndFrameCapture.unwrap()(device_handle, window_handle) }; } Self::NotAvailable { ref reason } => { - log::warn!("Could not end RenderDoc frame capture: {}", reason) + log::warn!("Could not end RenderDoc frame capture: {reason}") } }; } diff --git a/wgpu-hal/src/dx12/adapter.rs b/wgpu-hal/src/dx12/adapter.rs index 42a8e6711..5c0bee017 100644 --- a/wgpu-hal/src/dx12/adapter.rs +++ b/wgpu-hal/src/dx12/adapter.rs @@ -328,7 +328,7 @@ impl super::Adapter { tier3_practical_descriptor_limit, ), other => { - log::warn!("Unknown resource binding tier {:?}", other); + log::warn!("Unknown resource binding tier {other:?}"); ( Direct3D12::D3D12_MAX_SHADER_VISIBLE_DESCRIPTOR_HEAP_SIZE_TIER_1, 8, diff --git a/wgpu-hal/src/dx12/command.rs b/wgpu-hal/src/dx12/command.rs index 329534559..edfea952e 100644 --- a/wgpu-hal/src/dx12/command.rs +++ b/wgpu-hal/src/dx12/command.rs @@ -198,7 +198,7 @@ impl super::CommandEncoder { self.pass.dirty_root_elements ^= 1 << index; match self.pass.root_elements[index as usize] { - super::RootElement::Empty => log::error!("Root index {} is not bound", index), + super::RootElement::Empty => log::error!("Root index {index} is not bound"), super::RootElement::Constant => { let info = self.pass.layout.root_constant_info.as_ref().unwrap(); diff --git a/wgpu-hal/src/dx12/descriptor.rs b/wgpu-hal/src/dx12/descriptor.rs index 54cf6fa8b..f57ba46e1 100644 --- a/wgpu-hal/src/dx12/descriptor.rs +++ b/wgpu-hal/src/dx12/descriptor.rs @@ -96,7 +96,7 @@ impl GeneralHeap { pub(super) fn allocate_slice(&self, count: u64) -> Result { let range = self.ranges.lock().allocate_range(count).map_err(|err| { - log::error!("Unable to allocate descriptors: {:?}", err); + log::error!("Unable to allocate descriptors: {err:?}"); crate::DeviceError::OutOfMemory })?; Ok(range.start) diff --git a/wgpu-hal/src/dx12/device.rs b/wgpu-hal/src/dx12/device.rs index 19e7743d6..7d245e8ce 100644 --- a/wgpu-hal/src/dx12/device.rs +++ b/wgpu-hal/src/dx12/device.rs @@ -342,10 +342,7 @@ impl super::Device { (source, entry_point) }; log::info!( - "Naga generated shader for {:?} at {:?}:\n{}", - entry_point, - naga_stage, - source + "Naga generated shader for {entry_point:?} at {naga_stage:?}:\n{source}" ); ShaderCacheKey { @@ -1584,7 +1581,7 @@ impl crate::Device for super::Device { let buffer_size = (sampler_indexes.len() * size_of::()) as u64; let label = if let Some(label) = desc.label { - Cow::Owned(format!("{} (Internal Sampler Index Buffer)", label)) + Cow::Owned(format!("{label} (Internal Sampler Index Buffer)")) } else { Cow::Borrowed("Internal Sampler Index Buffer") }; @@ -2123,11 +2120,7 @@ impl crate::Device for super::Device { } }; - log::trace!( - "Waiting for fence value {} for {:?}", - value, - remaining_wait_duration - ); + log::trace!("Waiting for fence value {value} for {remaining_wait_duration:?}"); match unsafe { Threading::WaitForSingleObject( @@ -2145,13 +2138,13 @@ impl crate::Device for super::Device { break Ok(false); } other => { - log::error!("Unexpected wait status: 0x{:?}", other); + log::error!("Unexpected wait status: 0x{other:?}"); break Err(crate::DeviceError::Lost); } }; fence_value = unsafe { fence.raw.GetCompletedValue() }; - log::trace!("Wait complete! Fence actual value: {}", fence_value); + log::trace!("Wait complete! Fence actual value: {fence_value}"); if fence_value >= value { break Ok(true); diff --git a/wgpu-hal/src/dx12/mod.rs b/wgpu-hal/src/dx12/mod.rs index a41796331..a102006ac 100644 --- a/wgpu-hal/src/dx12/mod.rs +++ b/wgpu-hal/src/dx12/mod.rs @@ -1195,7 +1195,7 @@ impl SwapChain { Foundation::WAIT_OBJECT_0 => Ok(true), Foundation::WAIT_TIMEOUT => Ok(false), other => { - log::error!("Unexpected wait status: 0x{:x?}", other); + log::error!("Unexpected wait status: 0x{other:x?}"); Err(crate::SurfaceError::Lost) } } @@ -1316,7 +1316,7 @@ impl crate::Surface for Surface { }; let swap_chain1 = swap_chain1.map_err(|err| { - log::error!("SwapChain creation error: {}", err); + log::error!("SwapChain creation error: {err}"); crate::SurfaceError::Other("swapchain creation") })?; diff --git a/wgpu-hal/src/dx12/sampler.rs b/wgpu-hal/src/dx12/sampler.rs index 9a069475e..4b58a0b42 100644 --- a/wgpu-hal/src/dx12/sampler.rs +++ b/wgpu-hal/src/dx12/sampler.rs @@ -226,8 +226,7 @@ impl SamplerHeap { let Entry::Occupied(mut hash_map_entry) = state.mapping.entry(HashableSamplerDesc(desc)) else { log::error!( - "Tried to destroy a sampler that doesn't exist. Sampler description: {:#?}", - desc + "Tried to destroy a sampler that doesn't exist. Sampler description: {desc:#?}" ); return; }; diff --git a/wgpu-hal/src/dx12/suballocation.rs b/wgpu-hal/src/dx12/suballocation.rs index 8547f1300..8cee41023 100644 --- a/wgpu-hal/src/dx12/suballocation.rs +++ b/wgpu-hal/src/dx12/suballocation.rs @@ -106,7 +106,7 @@ impl Allocator { }; let allocator = gpu_allocator::d3d12::Allocator::new(&allocator_desc).inspect_err(|e| { - log::error!("Failed to create d3d12 allocator, error: {}", e); + log::error!("Failed to create d3d12 allocator, error: {e}"); })?; Ok(Self { @@ -627,7 +627,7 @@ impl From for crate::DeviceError { match result { gpu_allocator::AllocationError::OutOfMemory => Self::OutOfMemory, gpu_allocator::AllocationError::FailedToMap(e) => { - log::error!("DX12 gpu-allocator: Failed to map: {}", e); + log::error!("DX12 gpu-allocator: Failed to map: {e}"); Self::Lost } gpu_allocator::AllocationError::NoCompatibleMemoryTypeFound => { @@ -639,15 +639,12 @@ impl From for crate::DeviceError { Self::Lost } gpu_allocator::AllocationError::InvalidAllocatorCreateDesc(e) => { - log::error!( - "DX12 gpu-allocator: Invalid Allocator Creation Description: {}", - e - ); + log::error!("DX12 gpu-allocator: Invalid Allocator Creation Description: {e}"); Self::Lost } gpu_allocator::AllocationError::Internal(e) => { - log::error!("DX12 gpu-allocator: Internal Error: {}", e); + log::error!("DX12 gpu-allocator: Internal Error: {e}"); Self::Lost } gpu_allocator::AllocationError::BarrierLayoutNeedsDevice10 diff --git a/wgpu-hal/src/gles/adapter.rs b/wgpu-hal/src/gles/adapter.rs index 952ff0c91..d9d2812cc 100644 --- a/wgpu-hal/src/gles/adapter.rs +++ b/wgpu-hal/src/gles/adapter.rs @@ -220,9 +220,9 @@ impl super::Adapter { let vendor = unsafe { gl.get_parameter_string(vendor_const) }; let renderer = unsafe { gl.get_parameter_string(renderer_const) }; let version = unsafe { gl.get_parameter_string(glow::VERSION) }; - log::debug!("Vendor: {}", vendor); - log::debug!("Renderer: {}", renderer); - log::debug!("Version: {}", version); + log::debug!("Vendor: {vendor}"); + log::debug!("Renderer: {renderer}"); + log::debug!("Version: {version}"); let full_ver = Self::parse_full_version(&version).ok(); let es_ver = full_ver.map_or_else(|| Self::parse_version(&version).ok(), |_| None); @@ -293,7 +293,7 @@ impl super::Adapter { } }; - log::debug!("Supported GL Extensions: {:#?}", extensions); + log::debug!("Supported GL Extensions: {extensions:#?}"); let supported = |(req_es_major, req_es_minor), (req_full_major, req_full_minor)| { let es_supported = es_ver @@ -909,7 +909,7 @@ impl super::Adapter { if !unsafe { gl.get_shader_compile_status(shader) } { let msg = unsafe { gl.get_shader_info_log(shader) }; if !msg.is_empty() { - log::error!("\tShader compile error: {}", msg); + log::error!("\tShader compile error: {msg}"); } unsafe { gl.delete_shader(shader) }; None @@ -946,7 +946,7 @@ impl super::Adapter { let linked_ok = unsafe { gl.get_program_link_status(program) }; let msg = unsafe { gl.get_program_info_log(program) }; if !msg.is_empty() { - log::warn!("Shader link error: {}", msg); + log::warn!("Shader link error: {msg}"); } if !linked_ok { return None; diff --git a/wgpu-hal/src/gles/device.rs b/wgpu-hal/src/gles/device.rs index 0f36f734b..be9cc03fb 100644 --- a/wgpu-hal/src/gles/device.rs +++ b/wgpu-hal/src/gles/device.rs @@ -188,17 +188,17 @@ impl super::Device { unsafe { gl.shader_source(raw, shader) }; unsafe { gl.compile_shader(raw) }; - log::debug!("\tCompiled shader {:?}", raw); + log::debug!("\tCompiled shader {raw:?}"); let compiled_ok = unsafe { gl.get_shader_compile_status(raw) }; let msg = unsafe { gl.get_shader_info_log(raw) }; if compiled_ok { if !msg.is_empty() { - log::warn!("\tCompile: {}", msg); + log::warn!("\tCompile: {msg}"); } Ok(raw) } else { - log::error!("\tShader compilation failed: {}", msg); + log::error!("\tShader compilation failed: {msg}"); unsafe { gl.delete_shader(raw) }; Err(crate::PipelineError::Linkage( map_naga_stage(naga_stage), @@ -286,7 +286,7 @@ impl super::Device { crate::PipelineError::Linkage(map_naga_stage(naga_stage), msg) })?; - log::debug!("Naga generated shader:\n{}", output); + log::debug!("Naga generated shader:\n{output}"); context.consume_reflection( gl, @@ -422,7 +422,7 @@ impl super::Device { unsafe { gl.delete_shader(shader) }; } - log::debug!("\tLinked program {:?}", program); + log::debug!("\tLinked program {program:?}"); let linked_ok = unsafe { gl.get_program_link_status(program) }; let msg = unsafe { gl.get_program_info_log(program) }; @@ -430,7 +430,7 @@ impl super::Device { return Err(crate::PipelineError::Linkage(has_stages, msg)); } if !msg.is_empty() { - log::warn!("\tLink: {}", msg); + log::warn!("\tLink: {msg}"); } if !private_caps.contains(PrivateCapabilities::SHADER_BINDING_LAYOUT) { @@ -438,7 +438,7 @@ impl super::Device { // in the shader. We can't remap storage buffers this way. unsafe { gl.use_program(Some(program)) }; for (ref name, (register, slot)) in name_binding_map { - log::trace!("Get binding {:?} from program {:?}", name, program); + log::trace!("Get binding {name:?} from program {program:?}"); match register { super::BindingRegister::UniformBuffers => { let index = unsafe { gl.get_uniform_block_index(program, name) }.unwrap(); @@ -448,11 +448,7 @@ impl super::Device { super::BindingRegister::StorageBuffers => { let index = unsafe { gl.get_shader_storage_block_index(program, name) }.unwrap(); - log::error!( - "Unable to re-map shader storage block {} to {}", - name, - index - ); + log::error!("Unable to re-map shader storage block {name} to {index}"); return Err(crate::DeviceError::Lost.into()); } super::BindingRegister::Textures | super::BindingRegister::Images => { diff --git a/wgpu-hal/src/gles/egl.rs b/wgpu-hal/src/gles/egl.rs index 65844ec78..ce1dd1299 100644 --- a/wgpu-hal/src/gles/egl.rs +++ b/wgpu-hal/src/gles/egl.rs @@ -98,13 +98,7 @@ unsafe extern "system" fn egl_debug_proc( unsafe { ffi::CStr::from_ptr(message_raw) }.to_string_lossy() }; - log::log!( - log_severity, - "EGL '{}' code 0x{:x}: {}", - command, - error, - message, - ); + log::log!(log_severity, "EGL '{command}' code 0x{error:x}: {message}",); } /// A simple wrapper around an X11 or Wayland display handle. @@ -239,7 +233,7 @@ fn choose_config( let mut attributes = Vec::with_capacity(9); for tier_max in (0..tiers.len()).rev() { let name = tiers[tier_max].0; - log::debug!("\tTrying {}", name); + log::debug!("\tTrying {name}"); attributes.clear(); for &(_, tier_attr) in tiers[..=tier_max].iter() { @@ -275,7 +269,7 @@ fn choose_config( log::warn!("No config found!"); } Err(e) => { - log::error!("error in choose_first_config: {:?}", e); + log::error!("error in choose_first_config: {e:?}"); } } } @@ -527,7 +521,7 @@ impl Inner { .query_string(Some(display), khronos_egl::EXTENSIONS) .unwrap() .to_string_lossy(); - log::debug!("Display vendor {:?}, version {:?}", vendor, version,); + log::debug!("Display vendor {vendor:?}, version {version:?}",); log::debug!( "Display extensions: {:#?}", display_extensions.split_whitespace().collect::>() @@ -717,11 +711,11 @@ impl Drop for Inner { .instance .destroy_context(self.egl.display, self.egl.raw) { - log::warn!("Error in destroy_context: {:?}", e); + log::warn!("Error in destroy_context: {e:?}"); } if let Err(e) = terminate_display(&self.egl.instance, self.egl.display) { - log::warn!("Error in terminate: {:?}", e); + log::warn!("Error in terminate: {e:?}"); } } } @@ -1200,7 +1194,7 @@ impl Surface { Some(self.egl.raw), ) .map_err(|e| { - log::error!("make_current(surface) failed: {}", e); + log::error!("make_current(surface) failed: {e}"); crate::SurfaceError::Lost })?; @@ -1244,7 +1238,7 @@ impl Surface { .instance .swap_buffers(self.egl.display, sc.surface) .map_err(|e| { - log::error!("swap_buffers failed: {}", e); + log::error!("swap_buffers failed: {e}"); crate::SurfaceError::Lost // TODO: should we unset the current context here? })?; @@ -1252,7 +1246,7 @@ impl Surface { .instance .make_current(self.egl.display, None, None, None) .map_err(|e| { - log::error!("make_current(null) failed: {}", e); + log::error!("make_current(null) failed: {e}"); crate::SurfaceError::Lost })?; @@ -1419,7 +1413,7 @@ impl crate::Surface for Surface { match raw_result { Ok(raw) => (raw, wl_window), Err(e) => { - log::warn!("Error in create_window_surface: {:?}", e); + log::warn!("Error in create_window_surface: {e:?}"); return Err(crate::SurfaceError::Lost); } } diff --git a/wgpu-hal/src/gles/mod.rs b/wgpu-hal/src/gles/mod.rs index 3500eb98c..94416086d 100644 --- a/wgpu-hal/src/gles/mod.rs +++ b/wgpu-hal/src/gles/mod.rs @@ -1100,11 +1100,7 @@ fn gl_debug_message_callback(source: u32, gltype: u32, id: u32, severity: u32, m let _ = std::panic::catch_unwind(|| { log::log!( log_severity, - "GLES: [{}/{}] ID {} : {}", - source_str, - type_str, - id, - message + "GLES: [{source_str}/{type_str}] ID {id} : {message}" ); }); diff --git a/wgpu-hal/src/lib.rs b/wgpu-hal/src/lib.rs index b9ab0c3c9..db5269ad4 100644 --- a/wgpu-hal/src/lib.rs +++ b/wgpu-hal/src/lib.rs @@ -225,6 +225,8 @@ clippy::missing_safety_doc, // It gets in the way a lot and does not prevent bugs in practice. clippy::pattern_type_mismatch, + // We should investigate these. + clippy::large_enum_variant )] #![warn( clippy::alloc_instead_of_core, diff --git a/wgpu-hal/src/metal/device.rs b/wgpu-hal/src/metal/device.rs index ef8e7c83a..f4a79de64 100644 --- a/wgpu-hal/src/metal/device.rs +++ b/wgpu-hal/src/metal/device.rs @@ -140,7 +140,7 @@ impl super::Device { Some((naga_stage, stage.entry_point)), stage.constants, ) - .map_err(|e| crate::PipelineError::PipelineConstants(stage_bit, format!("MSL: {:?}", e)))?; + .map_err(|e| crate::PipelineError::PipelineConstants(stage_bit, format!("MSL: {e:?}")))?; let ep_resources = &layout.per_stage_map[naga_stage]; @@ -193,7 +193,7 @@ impl super::Device { let (source, info) = naga::back::msl::write_string(&module, &module_info, &options, &pipeline_options) - .map_err(|e| crate::PipelineError::Linkage(stage_bit, format!("MSL: {:?}", e)))?; + .map_err(|e| crate::PipelineError::Linkage(stage_bit, format!("MSL: {e:?}")))?; log::debug!( "Naga generated shader for entry point '{}' and stage {:?}\n{}", @@ -215,8 +215,8 @@ impl super::Device { .lock() .new_library_with_source(source.as_ref(), &options) .map_err(|err| { - log::warn!("Naga generated shader:\n{}", source); - crate::PipelineError::Linkage(stage_bit, format!("Metal: {}", err)) + log::warn!("Naga generated shader:\n{source}"); + crate::PipelineError::Linkage(stage_bit, format!("Metal: {err}")) })?; let ep_index = module @@ -227,7 +227,7 @@ impl super::Device { let ep = &module.entry_points[ep_index]; let translated_ep_name = info.entry_point_names[0] .as_ref() - .map_err(|e| crate::PipelineError::Linkage(stage_bit, format!("{}", e)))?; + .map_err(|e| crate::PipelineError::Linkage(stage_bit, format!("{e}")))?; let wg_size = MTLSize { width: ep.workgroup_size[0] as _, @@ -238,7 +238,7 @@ impl super::Device { let function = library .get_function(translated_ep_name, None) .map_err(|e| { - log::error!("get_function: {:?}", e); + log::error!("get_function: {e:?}"); crate::PipelineError::EntryPoint(naga_stage) })?; @@ -777,7 +777,7 @@ impl crate::Device for super::Device { || info.counters.textures > self.shared.private_caps.max_textures_per_stage || info.counters.samplers > self.shared.private_caps.max_samplers_per_stage { - log::error!("Resource limit exceeded: {:?}", info); + log::error!("Resource limit exceeded: {info:?}"); return Err(crate::DeviceError::OutOfMemory); } } @@ -1018,11 +1018,10 @@ impl crate::Device for super::Device { let device = self.shared.device.lock(); let library = device .new_library_with_source(&source, &options) - .map_err(|e| crate::ShaderError::Compilation(format!("MSL: {:?}", e)))?; + .map_err(|e| crate::ShaderError::Compilation(format!("MSL: {e:?}")))?; let function = library.get_function(&entry_point, None).map_err(|_| { crate::ShaderError::Compilation(format!( - "Entry point '{}' not found", - entry_point + "Entry point '{entry_point}' not found" )) })?; @@ -1289,7 +1288,7 @@ impl crate::Device for super::Device { .map_err(|e| { crate::PipelineError::Linkage( wgt::ShaderStages::VERTEX | wgt::ShaderStages::FRAGMENT, - format!("new_render_pipeline_state: {:?}", e), + format!("new_render_pipeline_state: {e:?}"), ) })?; @@ -1397,7 +1396,7 @@ impl crate::Device for super::Device { .map_err(|e| { crate::PipelineError::Linkage( wgt::ShaderStages::COMPUTE, - format!("new_compute_pipeline_state: {:?}", e), + format!("new_compute_pipeline_state: {e:?}"), ) })?; @@ -1472,7 +1471,7 @@ impl crate::Device for super::Device { match device.new_counter_sample_buffer_with_descriptor(&csb_desc) { Ok(buffer) => buffer, Err(err) => { - log::error!("Failed to create counter sample buffer: {:?}", err); + log::error!("Failed to create counter sample buffer: {err:?}"); return Err(crate::DeviceError::Unexpected); } }; @@ -1540,7 +1539,7 @@ impl crate::Device for super::Device { { Some((_, cmd_buf)) => cmd_buf, None => { - log::error!("No active command buffers for fence value {}", wait_value); + log::error!("No active command buffers for fence value {wait_value}"); return Err(crate::DeviceError::Lost); } }; diff --git a/wgpu-hal/src/metal/mod.rs b/wgpu-hal/src/metal/mod.rs index e1bd7ff0f..00223b2f7 100644 --- a/wgpu-hal/src/metal/mod.rs +++ b/wgpu-hal/src/metal/mod.rs @@ -338,7 +338,7 @@ unsafe impl Sync for AdapterShared {} impl AdapterShared { fn new(device: metal::Device) -> Self { let private_caps = PrivateCapabilities::new(&device); - log::debug!("{:#?}", private_caps); + log::debug!("{private_caps:#?}"); Self { disabilities: PrivateDisabilities::new(&device), diff --git a/wgpu-hal/src/metal/surface.rs b/wgpu-hal/src/metal/surface.rs index 444193d61..2a705cd79 100644 --- a/wgpu-hal/src/metal/surface.rs +++ b/wgpu-hal/src/metal/surface.rs @@ -139,7 +139,7 @@ impl crate::Surface for super::Surface { device: &super::Device, config: &crate::SurfaceConfiguration, ) -> Result<(), crate::SurfaceError> { - log::debug!("build swapchain {:?}", config); + log::debug!("build swapchain {config:?}"); let caps = &device.shared.private_caps; *self.swapchain_format.write() = Some(config.format); diff --git a/wgpu-hal/src/vulkan/adapter.rs b/wgpu-hal/src/vulkan/adapter.rs index 399c9d81a..24f0bfa91 100644 --- a/wgpu-hal/src/vulkan/adapter.rs +++ b/wgpu-hal/src/vulkan/adapter.rs @@ -1694,7 +1694,7 @@ impl super::Instance { }; let queue_flags = queue_families.first()?.queue_flags; if !queue_flags.contains(vk::QueueFlags::GRAPHICS) { - log::warn!("The first queue only exposes {:?}", queue_flags); + log::warn!("The first queue only exposes {queue_flags:?}"); return None; } @@ -1822,10 +1822,10 @@ impl super::Adapter { }); if !unsupported_extensions.is_empty() { - log::warn!("Missing extensions: {:?}", unsupported_extensions); + log::warn!("Missing extensions: {unsupported_extensions:?}"); } - log::debug!("Supported extensions: {:?}", supported_extensions); + log::debug!("Supported extensions: {supported_extensions:?}"); supported_extensions } @@ -2510,7 +2510,7 @@ impl crate::Adapter for super::Adapter { Ok(true) => (), Ok(false) => return None, Err(e) => { - log::error!("get_physical_device_surface_support: {}", e); + log::error!("get_physical_device_surface_support: {e}"); return None; } } @@ -2525,7 +2525,7 @@ impl crate::Adapter for super::Adapter { } { Ok(caps) => caps, Err(e) => { - log::error!("get_physical_device_surface_capabilities: {}", e); + log::error!("get_physical_device_surface_capabilities: {e}"); return None; } } @@ -2559,7 +2559,7 @@ impl crate::Adapter for super::Adapter { } { Ok(present_modes) => present_modes, Err(e) => { - log::error!("get_physical_device_surface_present_modes: {}", e); + log::error!("get_physical_device_surface_present_modes: {e}"); // Per definition of `SurfaceCapabilities`, there must be at least one present mode. return None; } @@ -2575,7 +2575,7 @@ impl crate::Adapter for super::Adapter { } { Ok(formats) => formats, Err(e) => { - log::error!("get_physical_device_surface_formats: {}", e); + log::error!("get_physical_device_surface_formats: {e}"); // Per definition of `SurfaceCapabilities`, there must be at least one present format. return None; } diff --git a/wgpu-hal/src/vulkan/conv.rs b/wgpu-hal/src/vulkan/conv.rs index 405c81844..5177896ac 100644 --- a/wgpu-hal/src/vulkan/conv.rs +++ b/wgpu-hal/src/vulkan/conv.rs @@ -484,7 +484,7 @@ pub fn map_vk_present_mode(mode: vk::PresentModeKHR) -> Option FIFO_LATEST_READY => None, _ => { - log::debug!("Unrecognized present mode {:?}", mode); + log::debug!("Unrecognized present mode {mode:?}"); None } } diff --git a/wgpu-hal/src/vulkan/drm.rs b/wgpu-hal/src/vulkan/drm.rs index a51268ebd..807260e33 100644 --- a/wgpu-hal/src/vulkan/drm.rs +++ b/wgpu-hal/src/vulkan/drm.rs @@ -54,7 +54,7 @@ impl super::Instance { let raw_devices = match unsafe { self.shared.raw.enumerate_physical_devices() } { Ok(devices) => devices, Err(err) => { - log::error!("enumerate_adapters: {}", err); + log::error!("enumerate_adapters: {err}"); Vec::new() } }; diff --git a/wgpu-hal/src/vulkan/instance.rs b/wgpu-hal/src/vulkan/instance.rs index 18b390177..ddccc5c3b 100644 --- a/wgpu-hal/src/vulkan/instance.rs +++ b/wgpu-hal/src/vulkan/instance.rs @@ -360,7 +360,7 @@ impl super::Instance { has_nv_optimus: bool, drop_callback: Option, ) -> Result { - log::debug!("Instance version: 0x{:x}", instance_api_version); + log::debug!("Instance version: 0x{instance_api_version:x}"); let debug_utils = if let Some(debug_utils_create_info) = debug_utils_create_info { if extensions.contains(&ext::debug_utils::NAME) { @@ -664,7 +664,7 @@ impl super::Instance { unsafe { entry.enumerate_instance_layer_properties() } }; let instance_layers = instance_layers.map_err(|e| { - log::debug!("enumerate_instance_layer_properties: {:?}", e); + log::debug!("enumerate_instance_layer_properties: {e:?}"); crate::InstanceError::with_source( String::from("enumerate_instance_layer_properties() failed"), e, @@ -962,7 +962,7 @@ impl crate::Instance for super::Instance { let raw_devices = match unsafe { self.shared.raw.enumerate_physical_devices() } { Ok(devices) => devices, Err(err) => { - log::error!("enumerate_adapters: {}", err); + log::error!("enumerate_adapters: {err}"); Vec::new() } }; diff --git a/wgpu-types/src/features.rs b/wgpu-types/src/features.rs index 53c2037c5..5880c6ff3 100644 --- a/wgpu-types/src/features.rs +++ b/wgpu-types/src/features.rs @@ -1575,10 +1575,10 @@ mod tests { use alloc::format; let feature = Features::CLEAR_TEXTURE; - assert_eq!(format!("{}", feature), "CLEAR_TEXTURE"); + assert_eq!(format!("{feature}"), "CLEAR_TEXTURE"); let feature = Features::CLEAR_TEXTURE | Features::BGRA8UNORM_STORAGE; - assert_eq!(format!("{}", feature), "CLEAR_TEXTURE | BGRA8UNORM_STORAGE"); + assert_eq!(format!("{feature}"), "CLEAR_TEXTURE | BGRA8UNORM_STORAGE"); } #[test] diff --git a/wgpu-types/src/instance.rs b/wgpu-types/src/instance.rs index a427b1b1c..79e3f7b25 100644 --- a/wgpu-types/src/instance.rs +++ b/wgpu-types/src/instance.rs @@ -13,7 +13,7 @@ use crate::{Backend, DownlevelFlags}; /// [`InstanceDescriptor::from_env_or_default()`] or [`InstanceDescriptor::with_env()`]. Each type /// within this descriptor has its own equivalent methods, so you can select which options you want /// to expose to influence from the environment. -#[derive(Clone, Debug)] +#[derive(Clone, Debug, Default)] pub struct InstanceDescriptor { /// Which [`Backends`] to enable. /// @@ -39,17 +39,6 @@ pub struct InstanceDescriptor { pub backend_options: BackendOptions, } -impl Default for InstanceDescriptor { - fn default() -> Self { - Self { - backends: Backends::all(), - flags: InstanceFlags::default(), - memory_budget_thresholds: MemoryBudgetThresholds::default(), - backend_options: BackendOptions::default(), - } - } -} - impl InstanceDescriptor { /// Choose instance options entirely from environment variables. /// diff --git a/wgpu-types/src/lib.rs b/wgpu-types/src/lib.rs index aff932966..e05822736 100644 --- a/wgpu-types/src/lib.rs +++ b/wgpu-types/src/lib.rs @@ -332,7 +332,7 @@ impl Backends { "webgpu" => Self::BROWSER_WEBGPU, "noop" => Self::NOOP, b => { - log::warn!("unknown backend string '{}'", b); + log::warn!("unknown backend string '{b}'"); continue; } } @@ -3668,7 +3668,7 @@ impl TextureFormat { // Two chroma bytes per block, one luma byte per block Self::NV12 => 3, f => { - log::warn!("Memory footprint for format {:?} is not implemented", f); + log::warn!("Memory footprint for format {f:?} is not implemented"); 0 } }, diff --git a/wgpu/src/backend/webgpu.rs b/wgpu/src/backend/webgpu.rs index 1cc99ee47..deaea79e7 100644 --- a/wgpu/src/backend/webgpu.rs +++ b/wgpu/src/backend/webgpu.rs @@ -116,11 +116,7 @@ fn map_utf16_to_utf8_offset(utf16_offset: u32, text: &str) -> u32 { if utf16_i >= utf16_offset { text.len() as u32 } else { - log::error!( - "UTF16 offset {} is out of bounds for string {}", - utf16_offset, - text - ); + log::error!("UTF16 offset {utf16_offset} is out of bounds for string {text}"); u32::MAX } } @@ -2493,16 +2489,12 @@ impl dispatch::QueueInterface for WebQueue { } let write_size = u64::from(size); if write_size % wgt::COPY_BUFFER_ALIGNMENT != 0 { - log::error!( - "Copy size {} does not respect `COPY_BUFFER_ALIGNMENT`", - size - ); + log::error!("Copy size {size} does not respect `COPY_BUFFER_ALIGNMENT`"); return None; } if offset % wgt::COPY_BUFFER_ALIGNMENT != 0 { log::error!( - "Buffer offset {} is not aligned to block size or `COPY_BUFFER_ALIGNMENT`", - offset + "Buffer offset {offset} is not aligned to block size or `COPY_BUFFER_ALIGNMENT`" ); return None; } @@ -2600,7 +2592,7 @@ impl dispatch::QueueInterface for WebQueue { match wasm_bindgen_futures::JsFuture::from(promise).await { Ok(_) => callback(), Err(error) => { - log::error!("on_submitted_work_done promise failed: {:?}", error); + log::error!("on_submitted_work_done promise failed: {error:?}"); callback(); } } diff --git a/wgpu/src/backend/wgpu_core.rs b/wgpu/src/backend/wgpu_core.rs index 8fed4d9f8..15fb57a45 100644 --- a/wgpu/src/backend/wgpu_core.rs +++ b/wgpu/src/backend/wgpu_core.rs @@ -1327,7 +1327,7 @@ impl dispatch::DeviceInterface for CoreDevice { .device_create_render_pipeline(self.id, &descriptor, None, None); if let Some(cause) = error { if let wgc::pipeline::CreateRenderPipelineError::Internal { stage, ref error } = cause { - log::error!("Shader translation error for stage {:?}: {}", stage, error); + log::error!("Shader translation error for stage {stage:?}: {error}"); log::error!("Please report it to https://github.com/gfx-rs/wgpu"); } self.context.handle_error( diff --git a/wgpu/src/lib.rs b/wgpu/src/lib.rs index 0a3ded75f..8a0a64b14 100644 --- a/wgpu/src/lib.rs +++ b/wgpu/src/lib.rs @@ -43,6 +43,10 @@ rust_2018_idioms, unsafe_op_in_unsafe_fn )] +#![allow( + // We need to investiagate these. + clippy::large_enum_variant +)] // NOTE: Keep this in sync with `wgpu-core`. #![cfg_attr(not(send_sync), allow(clippy::arc_with_non_send_sync))] #![cfg_attr(not(any(wgpu_core, webgpu)), allow(unused))] diff --git a/xtask/Cargo.toml b/xtask/Cargo.toml index 61fed29c9..330949337 100644 --- a/xtask/Cargo.toml +++ b/xtask/Cargo.toml @@ -2,7 +2,7 @@ name = "wgpu-xtask" version = "0.1.0" edition = "2021" -rust-version = "1.84" +rust-version.workspace = true publish = false [lints.rust] diff --git a/xtask/src/util.rs b/xtask/src/util.rs index 186426971..e38afde60 100644 --- a/xtask/src/util.rs +++ b/xtask/src/util.rs @@ -25,7 +25,7 @@ pub(crate) fn check_all_programs(programs: &[Program]) -> anyhow::Result<()> { } Err(e) => { log::error!("Checking for {binary_name} in PATH: ❌"); - panic!("Unknown IO error: {:?}", e); + panic!("Unknown IO error: {e:?}"); } } } diff --git a/xtask/src/vendor_web_sys.rs b/xtask/src/vendor_web_sys.rs index eaf30027c..f519ae786 100644 --- a/xtask/src/vendor_web_sys.rs +++ b/xtask/src/vendor_web_sys.rs @@ -180,7 +180,7 @@ pub(crate) fn run_vendor_web_sys(shell: Shell, mut args: Arguments) -> anyhow::R let git_url: Option = args.opt_value_from_str("--git-url")?; if let Some(url) = &git_url { - write!(&mut argument_description, " --git-url {}", url)?; + write!(&mut argument_description, " --git-url {url}")?; } let unknown_args = args.finish(); @@ -295,11 +295,11 @@ pub(crate) fn run_vendor_web_sys(shell: Shell, mut args: Arguments) -> anyhow::R module_file_contents.push_str("use web_sys::{Event, EventTarget};\n"); for &feature in WEB_SYS_FEATURES_NEEDED { - module_file_contents.push_str(&format!("mod gen_{};\n", feature)); - module_file_contents.push_str(&format!("pub use gen_{}::*;\n", feature)); + module_file_contents.push_str(&format!("mod gen_{feature};\n")); + module_file_contents.push_str(&format!("pub use gen_{feature}::*;\n")); } - shell.write_file(format!("{}/mod.rs", WEBGPU_SYS_PATH), module_file_contents)?; + shell.write_file(format!("{WEBGPU_SYS_PATH}/mod.rs"), module_file_contents)?; eprintln!("# Formatting files");