From 6178ce93e8537f823685e8c1b617e22ba93696e7 Mon Sep 17 00:00:00 2001 From: BD103 <59022059+BD103@users.noreply.github.com> Date: Sat, 14 Dec 2024 00:53:17 -0500 Subject: [PATCH] Fix Clippy lints in benchmarks (#16808) # Objective - Closes #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` --- benches/Cargo.toml | 24 +++++++++++++++++++ benches/benches/bevy_ecs/change_detection.rs | 2 +- benches/benches/bevy_ecs/empty_archetypes.rs | 6 ++--- .../iteration/iter_simple_foreach_hybrid.rs | 2 +- .../par_iter_simple_foreach_hybrid.rs | 2 +- benches/benches/bevy_ecs/observers/simple.rs | 2 +- .../benches/bevy_ecs/scheduling/schedule.rs | 2 +- benches/benches/bevy_math/bezier.rs | 2 +- benches/benches/bevy_reflect/function.rs | 1 + 9 files changed, 34 insertions(+), 9 deletions(-) diff --git a/benches/Cargo.toml b/benches/Cargo.toml index 4841570022..323dde9b17 100644 --- a/benches/Cargo.toml +++ b/benches/Cargo.toml @@ -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" diff --git a/benches/benches/bevy_ecs/change_detection.rs b/benches/benches/bevy_ecs/change_detection.rs index a07320cf18..ca57da93fa 100644 --- a/benches/benches/bevy_ecs/change_detection.rs +++ b/benches/benches/bevy_ecs/change_detection.rs @@ -350,7 +350,7 @@ fn multiple_archetype_none_changed_detection_generic< assert_eq!(0, count); }, criterion::BatchSize::LargeInput, - ) + ); }, ); } diff --git a/benches/benches/bevy_ecs/empty_archetypes.rs b/benches/benches/bevy_ecs/empty_archetypes.rs index 139f52ce84..daec970b74 100644 --- a/benches/benches/bevy_ecs/empty_archetypes.rs +++ b/benches/benches/bevy_ecs/empty_archetypes.rs @@ -180,7 +180,7 @@ fn empty_archetypes(criterion: &mut Criterion) { |bencher, &_| { bencher.iter(|| { schedule.run(&mut world); - }) + }); }, ); } @@ -211,7 +211,7 @@ fn empty_archetypes(criterion: &mut Criterion) { |bencher, &_| { bencher.iter(|| { schedule.run(&mut world); - }) + }); }, ); } @@ -242,7 +242,7 @@ fn empty_archetypes(criterion: &mut Criterion) { |bencher, &_| { bencher.iter(|| { schedule.run(&mut world); - }) + }); }, ); } diff --git a/benches/benches/bevy_ecs/iteration/iter_simple_foreach_hybrid.rs b/benches/benches/bevy_ecs/iteration/iter_simple_foreach_hybrid.rs index 0db614c9ac..e6ee627e18 100644 --- a/benches/benches/bevy_ecs/iteration/iter_simple_foreach_hybrid.rs +++ b/benches/benches/bevy_ecs/iteration/iter_simple_foreach_hybrid.rs @@ -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); } } diff --git a/benches/benches/bevy_ecs/iteration/par_iter_simple_foreach_hybrid.rs b/benches/benches/bevy_ecs/iteration/par_iter_simple_foreach_hybrid.rs index e2044c0956..9dbcba8785 100644 --- a/benches/benches/bevy_ecs/iteration/par_iter_simple_foreach_hybrid.rs +++ b/benches/benches/bevy_ecs/iteration/par_iter_simple_foreach_hybrid.rs @@ -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); } } diff --git a/benches/benches/bevy_ecs/observers/simple.rs b/benches/benches/bevy_ecs/observers/simple.rs index bc42710cf9..81dd8e021e 100644 --- a/benches/benches/bevy_ecs/observers/simple.rs +++ b/benches/benches/bevy_ecs/observers/simple.rs @@ -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); } }); }); diff --git a/benches/benches/bevy_ecs/scheduling/schedule.rs b/benches/benches/bevy_ecs/scheduling/schedule.rs index 1a428b5eb8..0450428535 100644 --- a/benches/benches/bevy_ecs/scheduling/schedule.rs +++ b/benches/benches/bevy_ecs/scheduling/schedule.rs @@ -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"); diff --git a/benches/benches/bevy_math/bezier.rs b/benches/benches/bevy_math/bezier.rs index c367cb3029..404ab08a63 100644 --- a/benches/benches/bevy_math/bezier.rs +++ b/benches/benches/bevy_math/bezier.rs @@ -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))); - }) + }); }); }); } diff --git a/benches/benches/bevy_reflect/function.rs b/benches/benches/bevy_reflect/function.rs index f40b9149ee..5398cc3da9 100644 --- a/benches/benches/bevy_reflect/function.rs +++ b/benches/benches/bevy_reflect/function.rs @@ -83,6 +83,7 @@ fn overload(c: &mut Criterion) { a + b } + #[expect(clippy::too_many_arguments)] fn complex( _: T0, _: T1,