Skip to content

Commit

Permalink
Fix clippy lints (2024-10-10) (#720)
Browse files Browse the repository at this point in the history
* Fix clippy
`needless_lifetime` lints

* Use to_string instead of format!()

* Ignore gentest clippy lints
  • Loading branch information
nicoburns authored Oct 10, 2024
1 parent b66bd6b commit c9d6a7b
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 14 deletions.
4 changes: 2 additions & 2 deletions benches/benches/tree_creation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion examples/custom_tree_owned_unsafe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
2 changes: 1 addition & 1 deletion examples/custom_tree_vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 6 additions & 0 deletions scripts/gentest/src/main.rs
Original file line number Diff line number Diff line change
@@ -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};
Expand Down Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion src/compute/grid/track_sizing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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>,
Expand Down
2 changes: 1 addition & 1 deletion src/style/grid.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
16 changes: 8 additions & 8 deletions src/tree/taffy_tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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> {
Expand Down Expand Up @@ -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>,
Expand All @@ -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>,
Expand Down Expand Up @@ -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>,
Expand All @@ -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>,
Expand All @@ -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>,
Expand All @@ -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>,
Expand Down

0 comments on commit c9d6a7b

Please sign in to comment.