From 0a5540f6a49d3873a5a3c54dd0bc2336cf0b2974 Mon Sep 17 00:00:00 2001 From: tanishka <109246904+taniishkaaa@users.noreply.github.com> Date: Sat, 5 Oct 2024 19:40:32 +0530 Subject: [PATCH] clippy: Fix warnings in `components/script` & `components/webgpu` (#33653) * clippy: Fix warnings in component/script & component/webgpu Signed-off-by: taniishkaaa * fix: use same variable name in if-let block Signed-off-by: taniishkaaa --------- Signed-off-by: taniishkaaa --- components/script/dom/gpucanvascontext.rs | 2 +- components/script/dom/htmlelement.rs | 4 +++- components/webgpu/swapchain.rs | 13 +++++-------- 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/components/script/dom/gpucanvascontext.rs b/components/script/dom/gpucanvascontext.rs index fbf07f74c23..618cc885229 100644 --- a/components/script/dom/gpucanvascontext.rs +++ b/components/script/dom/gpucanvascontext.rs @@ -255,7 +255,7 @@ impl GPUCanvasContext { .send(WebGPURequest::UpdateContext { context_id: self.context_id, size: drawing_buffer.size, - configuration: drawing_buffer.config.clone(), + configuration: drawing_buffer.config, }) .expect("Failed to update webgpu context"); } diff --git a/components/script/dom/htmlelement.rs b/components/script/dom/htmlelement.rs index 76bb021ea21..84807a3cbcb 100644 --- a/components/script/dom/htmlelement.rs +++ b/components/script/dom/htmlelement.rs @@ -534,7 +534,9 @@ impl HTMLElementMethods for HTMLElement { } // Step 8: If previous is a Text node, then merge with the next text node given previous. - previous.map(Self::merge_with_the_next_text_node); + if let Some(previous) = previous { + Self::merge_with_the_next_text_node(previous) + } Ok(()) } diff --git a/components/webgpu/swapchain.rs b/components/webgpu/swapchain.rs index c053526738e..078ab280d3d 100644 --- a/components/webgpu/swapchain.rs +++ b/components/webgpu/swapchain.rs @@ -385,14 +385,11 @@ impl crate::WGPU { // If configuration is not provided or presentation format is not valid // the context will be dummy until recreation - let format = config - .as_ref() - .map(|config| match config.format { - wgt::TextureFormat::Rgba8Unorm => Some(ImageFormat::RGBA8), - wgt::TextureFormat::Bgra8Unorm => Some(ImageFormat::BGRA8), - _ => None, - }) - .flatten(); + let format = config.as_ref().and_then(|config| match config.format { + wgt::TextureFormat::Rgba8Unorm => Some(ImageFormat::RGBA8), + wgt::TextureFormat::Bgra8Unorm => Some(ImageFormat::BGRA8), + _ => None, + }); let needs_image_update = if let Some(format) = format { let config = config.expect("Config should exist when valid format is available");