tawasuyu

tawasuyu/taffy

A high performance rust-powered UI layout library

Rust 501HTML 254C 19JavaScript 81414 Definiciones

Fix clippy lints (2024-10-10) (#720)

* Fix clippy
`needless_lifetime` lints

* Use to_string instead of format!()

* Ignore gentest clippy lints

c9d6a7b9630da168d6973034c9018548a5d90769 · por Nico Burns · (hace 2 años) · padre b66bd6bfa · ver el árbol en este commit

Delta semántico · 2

benches/benches/tree_creation.rs

scripts/gentest/src/main.rs

  • cambió por dentro fn main

7 archivos · +20 −14

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::Item> {
         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::Item> {
         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<Option<f32>>,
 }
 
-impl<'tree, 'oat, Tree, EstimateFunction> IntrisicSizeMeasurer<'tree, 'oat, Tree, EstimateFunction>
+impl<Tree, EstimateFunction> IntrisicSizeMeasurer<'_, '_, Tree, EstimateFunction>
 where
     Tree: LayoutPartialTree,
     EstimateFunction: Fn(&GridTrack, Option<f32>) -> Option<f32>,
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<Self, InvalidStringRepetitionValue> {
         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<Self::Item> {
@@ -238,7 +238,7 @@ where
 }
 
 // TraversePartialTree impl for TaffyView
-impl<'t, NodeContext, MeasureFunction> TraversePartialTree for TaffyView<'t, NodeContext, MeasureFunction>
+impl<NodeContext, MeasureFunction> TraversePartialTree for TaffyView<'_, NodeContext, MeasureFunction>
 where
     MeasureFunction:
         FnMut(Size<Option<f32>>, Size<AvailableSpace>, NodeId, Option<&mut NodeContext>, &Style) -> Size<f32>,
@@ -262,14 +262,14 @@ where
 }
 
 // TraverseTree impl for TaffyView
-impl<'t, NodeContext, MeasureFunction> TraverseTree for TaffyView<'t, NodeContext, MeasureFunction> where
+impl<NodeContext, MeasureFunction> TraverseTree for TaffyView<'_, NodeContext, MeasureFunction> where
     MeasureFunction:
         FnMut(Size<Option<f32>>, Size<AvailableSpace>, NodeId, Option<&mut NodeContext>, &Style) -> Size<f32>
 {
 }
 
 // LayoutPartialTree impl for TaffyView
-impl<'t, NodeContext, MeasureFunction> LayoutPartialTree for TaffyView<'t, NodeContext, MeasureFunction>
+impl<NodeContext, MeasureFunction> LayoutPartialTree for TaffyView<'_, NodeContext, MeasureFunction>
 where
     MeasureFunction:
         FnMut(Size<Option<f32>>, Size<AvailableSpace>, NodeId, Option<&mut NodeContext>, &Style) -> Size<f32>,
@@ -344,7 +344,7 @@ where
 }
 
 #[cfg(feature = "block_layout")]
-impl<'t, NodeContext, MeasureFunction> LayoutBlockContainer for TaffyView<'t, NodeContext, MeasureFunction>
+impl<NodeContext, MeasureFunction> LayoutBlockContainer for TaffyView<'_, NodeContext, MeasureFunction>
 where
     MeasureFunction:
         FnMut(Size<Option<f32>>, Size<AvailableSpace>, NodeId, Option<&mut NodeContext>, &Style) -> Size<f32>,
@@ -364,7 +364,7 @@ where
 }
 
 #[cfg(feature = "flexbox")]
-impl<'t, NodeContext, MeasureFunction> LayoutFlexboxContainer for TaffyView<'t, NodeContext, MeasureFunction>
+impl<NodeContext, MeasureFunction> LayoutFlexboxContainer for TaffyView<'_, NodeContext, MeasureFunction>
 where
     MeasureFunction:
         FnMut(Size<Option<f32>>, Size<AvailableSpace>, NodeId, Option<&mut NodeContext>, &Style) -> Size<f32>,
@@ -384,7 +384,7 @@ where
 }
 
 #[cfg(feature = "grid")]
-impl<'t, NodeContext, MeasureFunction> LayoutGridContainer for TaffyView<'t, NodeContext, MeasureFunction>
+impl<NodeContext, MeasureFunction> LayoutGridContainer for TaffyView<'_, NodeContext, MeasureFunction>
 where
     MeasureFunction:
         FnMut(Size<Option<f32>>, Size<AvailableSpace>, NodeId, Option<&mut NodeContext>, &Style) -> Size<f32>,
@@ -404,7 +404,7 @@ where
 }
 
 // RoundTree impl for TaffyView
-impl<'t, NodeContext, MeasureFunction> RoundTree for TaffyView<'t, NodeContext, MeasureFunction>
+impl<NodeContext, MeasureFunction> RoundTree for TaffyView<'_, NodeContext, MeasureFunction>
 where
     MeasureFunction:
         FnMut(Size<Option<f32>>, Size<AvailableSpace>, NodeId, Option<&mut NodeContext>, &Style) -> Size<f32>,