Skip to content

Commit

Permalink
Fix Clippy lints in benchmarks (bevyengine#16808)
Browse files Browse the repository at this point in the history
# Objective

- Closes bevyengine#16804.
- This copies over our lint configuration to our benchmarks and fixes
any lints.

## Solution

- Copied over our Clippy configuration from the root `Cargo.toml` to
`benches/Cargo.toml`.
- Fixed any warnings that Clippy emitted.

## Testing

- `cd benches && cargo clippy --benches`
  • Loading branch information
BD103 authored Dec 14, 2024
1 parent 897ffad commit 6178ce9
Show file tree
Hide file tree
Showing 9 changed files with 34 additions and 9 deletions.
24 changes: 24 additions & 0 deletions benches/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,30 @@ bevy_winit = { path = "../crates/bevy_winit", features = ["x11"] }
opt-level = 3
lto = true

[lints.clippy]
doc_markdown = "warn"
manual_let_else = "warn"
match_same_arms = "warn"
redundant_closure_for_method_calls = "warn"
redundant_else = "warn"
semicolon_if_nothing_returned = "warn"
type_complexity = "allow"
undocumented_unsafe_blocks = "warn"
unwrap_or_default = "warn"
needless_lifetimes = "allow"

ptr_as_ptr = "warn"
ptr_cast_constness = "warn"
ref_as_ptr = "warn"

# see: https://github.com/bevyengine/bevy/pull/15375#issuecomment-2366966219
too_long_first_doc_paragraph = "allow"

[lints.rust]
unexpected_cfgs = { level = "warn", check-cfg = ['cfg(docsrs_dep)'] }
unsafe_op_in_unsafe_fn = "warn"
unused_qualifications = "warn"

[[bench]]
name = "ecs"
path = "benches/bevy_ecs/main.rs"
Expand Down
2 changes: 1 addition & 1 deletion benches/benches/bevy_ecs/change_detection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ fn multiple_archetype_none_changed_detection_generic<
assert_eq!(0, count);
},
criterion::BatchSize::LargeInput,
)
);
},
);
}
Expand Down
6 changes: 3 additions & 3 deletions benches/benches/bevy_ecs/empty_archetypes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ fn empty_archetypes(criterion: &mut Criterion) {
|bencher, &_| {
bencher.iter(|| {
schedule.run(&mut world);
})
});
},
);
}
Expand Down Expand Up @@ -211,7 +211,7 @@ fn empty_archetypes(criterion: &mut Criterion) {
|bencher, &_| {
bencher.iter(|| {
schedule.run(&mut world);
})
});
},
);
}
Expand Down Expand Up @@ -242,7 +242,7 @@ fn empty_archetypes(criterion: &mut Criterion) {
|bencher, &_| {
bencher.iter(|| {
schedule.run(&mut world);
})
});
},
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,6 @@ impl<'w> Benchmark<'w> {
pub fn run(&mut self) {
self.1
.iter_mut(&mut self.0)
.for_each(|(mut v1, v2)| v1.0 += v2.0)
.for_each(|(mut v1, v2)| v1.0 += v2.0);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,6 @@ impl<'w> Benchmark<'w> {
pub fn run(&mut self) {
self.1
.par_iter_mut(&mut self.0)
.for_each(|(mut v1, v2)| v1.0 += v2.0)
.for_each(|(mut v1, v2)| v1.0 += v2.0);
}
}
2 changes: 1 addition & 1 deletion benches/benches/bevy_ecs/observers/simple.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ pub fn observe_simple(criterion: &mut Criterion) {
world.add_observer(empty_listener_base);
bencher.iter(|| {
for _ in 0..10000 {
world.trigger(EventBase)
world.trigger(EventBase);
}
});
});
Expand Down
2 changes: 1 addition & 1 deletion benches/benches/bevy_ecs/scheduling/schedule.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ pub fn build_schedule(criterion: &mut Criterion) {
}

pub fn empty_schedule_run(criterion: &mut Criterion) {
let mut app = bevy_app::App::default();
let mut app = App::default();

let mut group = criterion.benchmark_group("run_empty_schedule");

Expand Down
2 changes: 1 addition & 1 deletion benches/benches/bevy_math/bezier.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ fn easing(c: &mut Criterion) {
b.iter(|| {
(0..1000).map(|i| i as f32 / 1000.0).for_each(|t| {
black_box(cubic_bezier.ease(black_box(t)));
})
});
});
});
}
Expand Down
1 change: 1 addition & 0 deletions benches/benches/bevy_reflect/function.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ fn overload(c: &mut Criterion) {
a + b
}

#[expect(clippy::too_many_arguments)]
fn complex<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9>(
_: T0,
_: T1,
Expand Down

0 comments on commit 6178ce9

Please sign in to comment.