From c9d6a7b9630da168d6973034c9018548a5d90769 Mon Sep 17 00:00:00 2001 From: Nico Burns Date: Fri, 11 Oct 2024 00:11:54 +0100 Subject: [PATCH] Fix clippy lints (2024-10-10) (#720) * Fix clippy `needless_lifetime` lints * Use to_string instead of format!() * Ignore gentest clippy lints --- benches/benches/tree_creation.rs | 4 ++-- examples/custom_tree_owned_unsafe.rs | 2 +- examples/custom_tree_vec.rs | 2 +- scripts/gentest/src/main.rs | 6 ++++++ src/compute/grid/track_sizing.rs | 2 +- src/style/grid.rs | 2 +- src/tree/taffy_tree.rs | 16 ++++++++-------- 7 files changed, 20 insertions(+), 14 deletions(-) diff --git a/benches/benches/tree_creation.rs b/benches/benches/tree_creation.rs index 25e9889fd..52c9052eb 100644 --- a/benches/benches/tree_creation.rs +++ b/benches/benches/tree_creation.rs @@ -73,7 +73,7 @@ fn taffy_benchmarks(c: &mut Criterion) { std::hint::black_box(root); }) }); - let benchmark_id = BenchmarkId::new(format!("TaffyTree::new"), node_count); + let benchmark_id = BenchmarkId::new("TaffyTree::new".to_string(), node_count); group.bench_with_input(benchmark_id, node_count, |b, &node_count| { b.iter(|| { let (tree, root) = build_taffy_flat_hierarchy(node_count, false); @@ -82,7 +82,7 @@ fn taffy_benchmarks(c: &mut Criterion) { }) }); - let benchmark_id = BenchmarkId::new(format!("TaffyTree::with_capacity"), node_count); + let benchmark_id = BenchmarkId::new("TaffyTree::with_capacity".to_string(), node_count); group.bench_with_input(benchmark_id, node_count, |b, &node_count| { b.iter(|| { let (tree, root) = build_taffy_flat_hierarchy(node_count, true); diff --git a/examples/custom_tree_owned_unsafe.rs b/examples/custom_tree_owned_unsafe.rs index d41697b4c..fa0babc18 100644 --- a/examples/custom_tree_owned_unsafe.rs +++ b/examples/custom_tree_owned_unsafe.rs @@ -93,7 +93,7 @@ impl Node { } struct ChildIter<'a>(std::slice::Iter<'a, Node>); -impl<'a> Iterator for ChildIter<'a> { +impl Iterator for ChildIter<'_> { type Item = NodeId; fn next(&mut self) -> Option { self.0.next().map(|c| NodeId::from(c as *const Node as usize)) diff --git a/examples/custom_tree_vec.rs b/examples/custom_tree_vec.rs index 98ef83f7c..b2a4b4c5a 100644 --- a/examples/custom_tree_vec.rs +++ b/examples/custom_tree_vec.rs @@ -113,7 +113,7 @@ impl Tree { } struct ChildIter<'a>(std::slice::Iter<'a, usize>); -impl<'a> Iterator for ChildIter<'a> { +impl Iterator for ChildIter<'_> { type Item = NodeId; fn next(&mut self) -> Option { self.0.next().copied().map(NodeId::from) diff --git a/scripts/gentest/src/main.rs b/scripts/gentest/src/main.rs index 6a5d0ff16..588cb54b7 100644 --- a/scripts/gentest/src/main.rs +++ b/scripts/gentest/src/main.rs @@ -1,3 +1,6 @@ +// This is a spurious warning. See https://github.com/rust-lang/rust-clippy/issues/13535 +#![allow(clippy::needless_return)] + use std::fs::{self, OpenOptions}; use std::io::Write; use std::path::{Path, PathBuf}; @@ -77,6 +80,9 @@ async fn main() { info!("starting webdriver instance"); let webdriver_url = "http://localhost:4444"; + + // TODO: call `.wait()` at an appropriate time (probably at the end of the process?) + #[allow(clippy::zombie_processes)] let mut webdriver_handle = Command::new("chromedriver") .arg("--port=4444") .spawn() diff --git a/src/compute/grid/track_sizing.rs b/src/compute/grid/track_sizing.rs index 891da015e..622f3a6f9 100644 --- a/src/compute/grid/track_sizing.rs +++ b/src/compute/grid/track_sizing.rs @@ -83,7 +83,7 @@ where inner_node_size: Size>, } -impl<'tree, 'oat, Tree, EstimateFunction> IntrisicSizeMeasurer<'tree, 'oat, Tree, EstimateFunction> +impl IntrisicSizeMeasurer<'_, '_, Tree, EstimateFunction> where Tree: LayoutPartialTree, EstimateFunction: Fn(&GridTrack, Option) -> Option, diff --git a/src/style/grid.rs b/src/style/grid.rs index 406cc2265..c5eecab5b 100644 --- a/src/style/grid.rs +++ b/src/style/grid.rs @@ -649,7 +649,7 @@ impl core::fmt::Display for InvalidStringRepetitionValue { f.write_str("&str can only be converted to GridTrackRepetition if it's value is 'auto-fit' or 'auto-fill'") } } -impl<'a> TryFrom<&'a str> for GridTrackRepetition { +impl TryFrom<&str> for GridTrackRepetition { type Error = InvalidStringRepetitionValue; fn try_from(value: &str) -> Result { match value { diff --git a/src/tree/taffy_tree.rs b/src/tree/taffy_tree.rs index aabb8495e..958902b31 100644 --- a/src/tree/taffy_tree.rs +++ b/src/tree/taffy_tree.rs @@ -156,7 +156,7 @@ impl Default for TaffyTree { /// Iterator that wraps a slice of nodes, lazily converting them to u64 pub struct TaffyTreeChildIter<'a>(core::slice::Iter<'a, NodeId>); -impl<'a> Iterator for TaffyTreeChildIter<'a> { +impl Iterator for TaffyTreeChildIter<'_> { type Item = NodeId; fn next(&mut self) -> Option { @@ -238,7 +238,7 @@ where } // TraversePartialTree impl for TaffyView -impl<'t, NodeContext, MeasureFunction> TraversePartialTree for TaffyView<'t, NodeContext, MeasureFunction> +impl TraversePartialTree for TaffyView<'_, NodeContext, MeasureFunction> where MeasureFunction: FnMut(Size>, Size, NodeId, Option<&mut NodeContext>, &Style) -> Size, @@ -262,14 +262,14 @@ where } // TraverseTree impl for TaffyView -impl<'t, NodeContext, MeasureFunction> TraverseTree for TaffyView<'t, NodeContext, MeasureFunction> where +impl TraverseTree for TaffyView<'_, NodeContext, MeasureFunction> where MeasureFunction: FnMut(Size>, Size, NodeId, Option<&mut NodeContext>, &Style) -> Size { } // LayoutPartialTree impl for TaffyView -impl<'t, NodeContext, MeasureFunction> LayoutPartialTree for TaffyView<'t, NodeContext, MeasureFunction> +impl LayoutPartialTree for TaffyView<'_, NodeContext, MeasureFunction> where MeasureFunction: FnMut(Size>, Size, NodeId, Option<&mut NodeContext>, &Style) -> Size, @@ -344,7 +344,7 @@ where } #[cfg(feature = "block_layout")] -impl<'t, NodeContext, MeasureFunction> LayoutBlockContainer for TaffyView<'t, NodeContext, MeasureFunction> +impl LayoutBlockContainer for TaffyView<'_, NodeContext, MeasureFunction> where MeasureFunction: FnMut(Size>, Size, NodeId, Option<&mut NodeContext>, &Style) -> Size, @@ -364,7 +364,7 @@ where } #[cfg(feature = "flexbox")] -impl<'t, NodeContext, MeasureFunction> LayoutFlexboxContainer for TaffyView<'t, NodeContext, MeasureFunction> +impl LayoutFlexboxContainer for TaffyView<'_, NodeContext, MeasureFunction> where MeasureFunction: FnMut(Size>, Size, NodeId, Option<&mut NodeContext>, &Style) -> Size, @@ -384,7 +384,7 @@ where } #[cfg(feature = "grid")] -impl<'t, NodeContext, MeasureFunction> LayoutGridContainer for TaffyView<'t, NodeContext, MeasureFunction> +impl LayoutGridContainer for TaffyView<'_, NodeContext, MeasureFunction> where MeasureFunction: FnMut(Size>, Size, NodeId, Option<&mut NodeContext>, &Style) -> Size, @@ -404,7 +404,7 @@ where } // RoundTree impl for TaffyView -impl<'t, NodeContext, MeasureFunction> RoundTree for TaffyView<'t, NodeContext, MeasureFunction> +impl RoundTree for TaffyView<'_, NodeContext, MeasureFunction> where MeasureFunction: FnMut(Size>, Size, NodeId, Option<&mut NodeContext>, &Style) -> Size,