From 3d6b9637c3b1c9f3c654a3ecef7a247cfd6edef3 Mon Sep 17 00:00:00 2001 From: Yuri Astrakhan Date: Tue, 19 Sep 2023 01:31:10 -0400 Subject: Chore: Inline format args for ease of reading A minor cleanup to inline all simple cases of format arguments. Makes the format strings just a bit easier to read. --- wgpu/src/image/atlas.rs | 8 ++++---- wgpu/src/image/vector.rs | 2 +- wgpu/src/window/compositor.rs | 6 +++--- 3 files changed, 8 insertions(+), 8 deletions(-) (limited to 'wgpu') diff --git a/wgpu/src/image/atlas.rs b/wgpu/src/image/atlas.rs index e3de1290..1253496b 100644 --- a/wgpu/src/image/atlas.rs +++ b/wgpu/src/image/atlas.rs @@ -86,7 +86,7 @@ impl Atlas { entry }; - log::info!("Allocated atlas entry: {:?}", entry); + log::info!("Allocated atlas entry: {entry:?}"); // It is a webgpu requirement that: // BufferCopyView.layout.bytes_per_row % wgpu::COPY_BYTES_PER_ROW_ALIGNMENT == 0 @@ -139,13 +139,13 @@ impl Atlas { } } - log::info!("Current atlas: {:?}", self); + log::info!("Current atlas: {self:?}"); Some(entry) } pub fn remove(&mut self, entry: &Entry) { - log::info!("Removing atlas entry: {:?}", entry); + log::info!("Removing atlas entry: {entry:?}"); match entry { Entry::Contiguous(allocation) => { @@ -258,7 +258,7 @@ impl Atlas { } fn deallocate(&mut self, allocation: &Allocation) { - log::info!("Deallocating atlas: {:?}", allocation); + log::info!("Deallocating atlas: {allocation:?}"); match allocation { Allocation::Full { layer } => { diff --git a/wgpu/src/image/vector.rs b/wgpu/src/image/vector.rs index 2c03d36b..6582bb82 100644 --- a/wgpu/src/image/vector.rs +++ b/wgpu/src/image/vector.rs @@ -152,7 +152,7 @@ impl Cache { let allocation = atlas.upload(device, encoder, width, height, &rgba)?; - log::debug!("allocating {} {}x{}", id, width, height); + log::debug!("allocating {id} {width}x{height}"); let _ = self.svg_hits.insert(id); let _ = self.rasterized_hits.insert(key); diff --git a/wgpu/src/window/compositor.rs b/wgpu/src/window/compositor.rs index a9521a15..1ddbe5fe 100644 --- a/wgpu/src/window/compositor.rs +++ b/wgpu/src/window/compositor.rs @@ -35,7 +35,7 @@ impl Compositor { ..Default::default() }); - log::info!("{:#?}", settings); + log::info!("{settings:#?}"); #[cfg(not(target_arch = "wasm32"))] if log::max_level() >= log::LevelFilter::Info { @@ -43,7 +43,7 @@ impl Compositor { .enumerate_adapters(settings.internal_backend) .map(|adapter| adapter.get_info()) .collect(); - log::info!("Available adapters: {:#?}", available_adapters); + log::info!("Available adapters: {available_adapters:#?}"); } #[allow(unsafe_code)] @@ -83,7 +83,7 @@ impl Compositor { }) })?; - log::info!("Selected format: {:?}", format); + log::info!("Selected format: {format:?}"); #[cfg(target_arch = "wasm32")] let limits = [wgpu::Limits::downlevel_webgl2_defaults() -- cgit From c997aad85d7ee6e77085e50e5e599002549d228f Mon Sep 17 00:00:00 2001 From: Yuri Astrakhan Date: Tue, 19 Sep 2023 01:46:46 -0400 Subject: Chore: Apply clippy map transformations Convert `.map().unwrap_or()` to `.map_or()` and similar transformations. --- wgpu/src/image/vector.rs | 2 +- wgpu/src/triangle.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'wgpu') diff --git a/wgpu/src/image/vector.rs b/wgpu/src/image/vector.rs index 2c03d36b..1ac82bc7 100644 --- a/wgpu/src/image/vector.rs +++ b/wgpu/src/image/vector.rs @@ -56,7 +56,7 @@ impl Cache { .ok() }); - tree.map(Svg::Loaded).unwrap_or(Svg::NotFound) + tree.map_or(Svg::NotFound, Svg::Loaded) } svg::Data::Bytes(bytes) => { match usvg::Tree::from_data(bytes, &usvg::Options::default()) { diff --git a/wgpu/src/triangle.rs b/wgpu/src/triangle.rs index d430e607..7e1bd9cc 100644 --- a/wgpu/src/triangle.rs +++ b/wgpu/src/triangle.rs @@ -349,7 +349,7 @@ fn multisample_state( antialiasing: Option, ) -> wgpu::MultisampleState { wgpu::MultisampleState { - count: antialiasing.map(|a| a.sample_count()).unwrap_or(1), + count: antialiasing.map_or(1, Antialiasing::sample_count), mask: !0, alpha_to_coverage_enabled: false, } -- cgit From 34f07b60273d6cfe13834af54cd0e24d34569387 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Wed, 20 Sep 2023 04:11:52 +0200 Subject: Fix `clippy::semicolon_if_nothing_returned` --- wgpu/src/buffer.rs | 2 +- wgpu/src/geometry.rs | 4 ++-- wgpu/src/image/atlas.rs | 2 +- wgpu/src/layer.rs | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) (limited to 'wgpu') diff --git a/wgpu/src/buffer.rs b/wgpu/src/buffer.rs index 94122187..ef00c58f 100644 --- a/wgpu/src/buffer.rs +++ b/wgpu/src/buffer.rs @@ -87,7 +87,7 @@ impl Buffer { /// Clears any temporary data (i.e. offsets) from the buffer. pub fn clear(&mut self) { - self.offsets.clear() + self.offsets.clear(); } /// Returns the offset at `index`, if it exists. diff --git a/wgpu/src/geometry.rs b/wgpu/src/geometry.rs index 63a59c05..655362b7 100644 --- a/wgpu/src/geometry.rs +++ b/wgpu/src/geometry.rs @@ -480,7 +480,7 @@ impl Frame { }, size: self.size, }), - )) + )); } } Buffer::Gradient(buffer) => { @@ -493,7 +493,7 @@ impl Frame { }, size: self.size, }), - )) + )); } } } diff --git a/wgpu/src/image/atlas.rs b/wgpu/src/image/atlas.rs index 1253496b..e8ca4bd3 100644 --- a/wgpu/src/image/atlas.rs +++ b/wgpu/src/image/atlas.rs @@ -104,7 +104,7 @@ impl Atlas { padded_data[offset..offset + 4 * width as usize].copy_from_slice( &data[row * 4 * width as usize..(row + 1) * 4 * width as usize], - ) + ); } match &entry { diff --git a/wgpu/src/layer.rs b/wgpu/src/layer.rs index 7a5a0f7c..d20dbe66 100644 --- a/wgpu/src/layer.rs +++ b/wgpu/src/layer.rs @@ -202,7 +202,7 @@ impl<'a> Layer<'a> { translation, primitive, current_layer, - ) + ); } } Primitive::Clip { bounds, content } => { -- cgit From 42ed90bc6f92b2085d193e7f143430b8d3847c21 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Wed, 20 Sep 2023 04:51:08 +0200 Subject: Fix `clippy::default_trait_access` --- wgpu/src/color.rs | 6 +++--- wgpu/src/text.rs | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'wgpu') diff --git a/wgpu/src/color.rs b/wgpu/src/color.rs index a1025601..20827e3c 100644 --- a/wgpu/src/color.rs +++ b/wgpu/src/color.rs @@ -12,7 +12,7 @@ pub fn convert( let sampler = device.create_sampler(&wgpu::SamplerDescriptor { label: Some("iced_wgpu.offscreen.sampler"), - ..Default::default() + ..wgpu::SamplerDescriptor::default() }); //sampler in 0 @@ -102,10 +102,10 @@ pub fn convert( primitive: wgpu::PrimitiveState { topology: wgpu::PrimitiveTopology::TriangleList, front_face: wgpu::FrontFace::Cw, - ..Default::default() + ..wgpu::PrimitiveState::default() }, depth_stencil: None, - multisample: Default::default(), + multisample: wgpu::MultisampleState::default(), multiview: None, }); diff --git a/wgpu/src/text.rs b/wgpu/src/text.rs index bd4f3e06..2a530cad 100644 --- a/wgpu/src/text.rs +++ b/wgpu/src/text.rs @@ -64,7 +64,7 @@ impl Pipeline { self.renderers.push(glyphon::TextRenderer::new( &mut self.atlas, device, - Default::default(), + wgpu::MultisampleState::default(), None, )); } -- cgit From caed50b277495e4375975f3f4e271b8fcbc0c33f Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Wed, 20 Sep 2023 05:03:25 +0200 Subject: Fix `clippy::match-wildcard-for-single-variants` --- wgpu/src/image/atlas.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'wgpu') diff --git a/wgpu/src/image/atlas.rs b/wgpu/src/image/atlas.rs index e8ca4bd3..789e35b4 100644 --- a/wgpu/src/image/atlas.rs +++ b/wgpu/src/image/atlas.rs @@ -237,7 +237,7 @@ impl Atlas { })); } } - _ => {} + Layer::Full => {} } } -- cgit From 14ba939e674ec4d9ca53b506ffa3259d30216e85 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Wed, 20 Sep 2023 05:19:24 +0200 Subject: Fix `clippy::unreadable_literal` --- wgpu/src/triangle.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'wgpu') diff --git a/wgpu/src/triangle.rs b/wgpu/src/triangle.rs index 7e1bd9cc..f8014ceb 100644 --- a/wgpu/src/triangle.rs +++ b/wgpu/src/triangle.rs @@ -329,12 +329,12 @@ impl Pipeline { fn fragment_target( texture_format: wgpu::TextureFormat, -) -> Option { - Some(wgpu::ColorTargetState { +) -> wgpu::ColorTargetState { + wgpu::ColorTargetState { format: texture_format, blend: Some(wgpu::BlendState::ALPHA_BLENDING), write_mask: wgpu::ColorWrites::ALL, - }) + } } fn primitive_state() -> wgpu::PrimitiveState { @@ -521,7 +521,7 @@ mod solid { fragment: Some(wgpu::FragmentState { module: &shader, entry_point: "solid_fs_main", - targets: &[triangle::fragment_target(format)], + targets: &[Some(triangle::fragment_target(format))], }), primitive: triangle::primitive_state(), depth_stencil: None, @@ -698,7 +698,7 @@ mod gradient { fragment: Some(wgpu::FragmentState { module: &shader, entry_point: "gradient_fs_main", - targets: &[triangle::fragment_target(format)], + targets: &[Some(triangle::fragment_target(format))], }), primitive: triangle::primitive_state(), depth_stencil: None, -- cgit From b27762554627b8e89f2b840b1a8a512e22d4cd87 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Wed, 20 Sep 2023 16:26:43 +0200 Subject: Revert "Chore: Apply clippy map transformations" This reverts commit c997aad85d7ee6e77085e50e5e599002549d228f. --- wgpu/src/image/vector.rs | 2 +- wgpu/src/triangle.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'wgpu') diff --git a/wgpu/src/image/vector.rs b/wgpu/src/image/vector.rs index e8baae4f..6582bb82 100644 --- a/wgpu/src/image/vector.rs +++ b/wgpu/src/image/vector.rs @@ -56,7 +56,7 @@ impl Cache { .ok() }); - tree.map_or(Svg::NotFound, Svg::Loaded) + tree.map(Svg::Loaded).unwrap_or(Svg::NotFound) } svg::Data::Bytes(bytes) => { match usvg::Tree::from_data(bytes, &usvg::Options::default()) { diff --git a/wgpu/src/triangle.rs b/wgpu/src/triangle.rs index f8014ceb..c55b93bf 100644 --- a/wgpu/src/triangle.rs +++ b/wgpu/src/triangle.rs @@ -349,7 +349,7 @@ fn multisample_state( antialiasing: Option, ) -> wgpu::MultisampleState { wgpu::MultisampleState { - count: antialiasing.map_or(1, Antialiasing::sample_count), + count: antialiasing.map(|a| a.sample_count()).unwrap_or(1), mask: !0, alpha_to_coverage_enabled: false, } -- cgit From b8ddd158da1b4e73e67fd090f8d36ed07f191874 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Wed, 20 Sep 2023 16:27:54 +0200 Subject: Simplify `map` call in `iced_wgpu::triangle` --- wgpu/src/triangle.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'wgpu') diff --git a/wgpu/src/triangle.rs b/wgpu/src/triangle.rs index c55b93bf..644c9f84 100644 --- a/wgpu/src/triangle.rs +++ b/wgpu/src/triangle.rs @@ -349,7 +349,7 @@ fn multisample_state( antialiasing: Option, ) -> wgpu::MultisampleState { wgpu::MultisampleState { - count: antialiasing.map(|a| a.sample_count()).unwrap_or(1), + count: antialiasing.map(Antialiasing::sample_count).unwrap_or(1), mask: !0, alpha_to_coverage_enabled: false, } -- cgit From f137d71e8fb926e784680d56d1cfa6817c3710a1 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Wed, 20 Sep 2023 16:40:03 +0200 Subject: Centralize `clippy` lints in `.cargo/config.toml` --- wgpu/src/lib.rs | 6 ------ 1 file changed, 6 deletions(-) (limited to 'wgpu') diff --git a/wgpu/src/lib.rs b/wgpu/src/lib.rs index 2f483751..6d26723e 100644 --- a/wgpu/src/lib.rs +++ b/wgpu/src/lib.rs @@ -26,14 +26,8 @@ //missing_docs, unsafe_code, unused_results, - clippy::extra_unused_lifetimes, - clippy::from_over_into, - clippy::needless_borrow, - clippy::new_without_default, - clippy::useless_conversion, rustdoc::broken_intra_doc_links )] -#![allow(clippy::inherent_to_string, clippy::type_complexity)] #![cfg_attr(docsrs, feature(doc_auto_cfg))] pub mod layer; pub mod primitive; -- cgit