From 9a7ea88d55c745076a55560a33222f3676a0f21b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A9ctor=20Ram=C3=B3n=20Jim=C3=A9nez?= Date: Thu, 15 May 2025 20:52:27 +0200 Subject: [PATCH] Fix `clippy` lints for Rust 1.87 --- Cargo.toml | 2 ++ widget/src/markdown.rs | 12 ++++-------- widget/src/slider.rs | 6 ++---- widget/src/stack.rs | 5 +---- widget/src/vertical_slider.rs | 6 ++---- 5 files changed, 11 insertions(+), 20 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 133c2362..4973715c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -220,6 +220,8 @@ unused_results = "deny" [workspace.lints.clippy] type-complexity = "allow" map-entry = "allow" +large-enum-variant = "allow" +result_large_err = "allow" semicolon_if_nothing_returned = "deny" trivially-copy-pass-by-ref = "deny" default_trait_access = "deny" diff --git a/widget/src/markdown.rs b/widget/src/markdown.rs index afcb5da2..f6360211 100644 --- a/widget/src/markdown.rs +++ b/widget/src/markdown.rs @@ -298,13 +298,11 @@ impl Span { span }; - let span = if let Some(link) = link.as_ref() { + if let Some(link) = link.as_ref() { span.color(style.link_color).link(link.clone()) } else { span - }; - - span + } } #[cfg(feature = "highlighter")] Span::Highlight { text, color, font } => { @@ -632,7 +630,7 @@ fn parse_with<'a>( code_language = (!language.is_empty()).then(|| language.into_string()); - let prev = if spans.is_empty() { + if spans.is_empty() { None } else { produce( @@ -641,9 +639,7 @@ fn parse_with<'a>( Item::Paragraph(Text::new(spans.drain(..).collect())), source, ) - }; - - prev + } } pulldown_cmark::Tag::MetadataBlock(_) => { metadata = true; diff --git a/widget/src/slider.rs b/widget/src/slider.rs index 1a2f8b9d..74225436 100644 --- a/widget/src/slider.rs +++ b/widget/src/slider.rs @@ -261,7 +261,7 @@ where let locate = |cursor_position: Point| -> Option { let bounds = layout.bounds(); - let new_value = if cursor_position.x <= bounds.x { + if cursor_position.x <= bounds.x { Some(*self.range.start()) } else if cursor_position.x >= bounds.x + bounds.width { Some(*self.range.end()) @@ -283,9 +283,7 @@ where let value = steps * step + start; T::from_f64(value.min(end)) - }; - - new_value + } }; let increment = |value: T| -> Option { diff --git a/widget/src/stack.rs b/widget/src/stack.rs index 5e10ff2c..ee81e4de 100644 --- a/widget/src/stack.rs +++ b/widget/src/stack.rs @@ -173,10 +173,7 @@ where let nodes = std::iter::once(base) .chain(self.children[1..].iter().zip(&mut tree.children[1..]).map( |(layer, tree)| { - let node = - layer.as_widget().layout(tree, renderer, &limits); - - node + layer.as_widget().layout(tree, renderer, &limits) }, )) .collect(); diff --git a/widget/src/vertical_slider.rs b/widget/src/vertical_slider.rs index 436c2345..c262eb8e 100644 --- a/widget/src/vertical_slider.rs +++ b/widget/src/vertical_slider.rs @@ -264,7 +264,7 @@ where let locate = |cursor_position: Point| -> Option { let bounds = layout.bounds(); - let new_value = if cursor_position.y >= bounds.y + bounds.height { + if cursor_position.y >= bounds.y + bounds.height { Some(*self.range.start()) } else if cursor_position.y <= bounds.y { Some(*self.range.end()) @@ -287,9 +287,7 @@ where let value = steps * step + start; T::from_f64(value.min(end)) - }; - - new_value + } }; let increment = |value: T| -> Option {