From dc76c02131c124d3e955f793494d27c0d666bfb0 Mon Sep 17 00:00:00 2001 From: Veetaha Date: Fri, 3 Oct 2025 10:24:12 +0000 Subject: [PATCH 1/2] Add some more assertions to eliminate dead code lints in tests --- bon/tests/integration/builder/attr_bon.rs | 4 +++- bon/tests/integration/builder/attr_const.rs | 6 ++---- bon/tests/integration/builder/attr_top_level_start_fn.rs | 9 ++++++--- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/bon/tests/integration/builder/attr_bon.rs b/bon/tests/integration/builder/attr_bon.rs index 936be0ab..48d53e76 100644 --- a/bon/tests/integration/builder/attr_bon.rs +++ b/bon/tests/integration/builder/attr_bon.rs @@ -102,7 +102,6 @@ fn receiver_variations() { } #[builder] - #[allow(dead_code)] fn mut_self_as_pin_mut_self(mut self: Pin<&mut Self>) { #[allow(clippy::self_assignment, unused_assignments)] { @@ -132,6 +131,9 @@ fn receiver_variations() { Sut::self_as_pin_mut_self(Pin::new(&mut sut)).call(); Pin::new(&mut sut).self_as_pin_mut_self().call(); + + Sut::mut_self_as_pin_mut_self(Pin::new(&mut sut)).call(); + Pin::new(&mut sut).mut_self_as_pin_mut_self().call(); } #[cfg(feature = "alloc")] diff --git a/bon/tests/integration/builder/attr_const.rs b/bon/tests/integration/builder/attr_const.rs index 495eb33b..e086fadd 100644 --- a/bon/tests/integration/builder/attr_const.rs +++ b/bon/tests/integration/builder/attr_const.rs @@ -205,8 +205,7 @@ mod msrv_1_61 { #[test] const fn test_function() { #[builder(const)] - #[allow(unreachable_pub)] - pub const fn sut(#[builder(getter)] _x: u32) {} + pub(crate) const fn sut(#[builder(getter)] _x: u32) {} sut().x(1).call(); } @@ -218,8 +217,7 @@ mod msrv_1_61 { #[bon] impl Sut { #[builder(const)] - #[allow(unreachable_pub)] - pub const fn sut(#[builder(getter)] _x: u32) {} + pub(crate) const fn sut(#[builder(getter)] _x: u32) {} } Sut::sut().x(1).call(); diff --git a/bon/tests/integration/builder/attr_top_level_start_fn.rs b/bon/tests/integration/builder/attr_top_level_start_fn.rs index 28fd9d10..2e0d4774 100644 --- a/bon/tests/integration/builder/attr_top_level_start_fn.rs +++ b/bon/tests/integration/builder/attr_top_level_start_fn.rs @@ -52,31 +52,34 @@ fn test_method() { fn test_function() { { #[builder(start_fn(name = sut_builder))] - #[allow(dead_code)] fn sut(arg1: bool, arg2: u32) -> impl fmt::Debug { (arg1, arg2) } + assert_debug_eq( + sut_builder().arg1(true).arg2(42).call(), + expect!["(true, 42)"], + ); assert_debug_eq(sut(true, 42), expect!["(true, 42)"]); } { #[builder(start_fn = sut_builder)] - #[allow(dead_code)] fn sut(arg1: u32) -> u32 { arg1 } + assert_debug_eq(sut_builder().arg1(42).call(), expect!["42"]); assert_debug_eq(sut(42), expect!["42"]); } { #[builder(start_fn(name = sut_builder, vis = ""))] - #[allow(dead_code)] fn sut(arg1: u32) -> u32 { arg1 } + assert_debug_eq(sut_builder().arg1(42).call(), expect!["42"]); assert_debug_eq(sut(42), expect!["42"]); } From 744d441d6b70b87a5024d3e448036bcffadc7569 Mon Sep 17 00:00:00 2001 From: Veetaha Date: Fri, 3 Oct 2025 10:43:50 +0000 Subject: [PATCH 2/2] Fix lint on nightly --- bon/tests/integration/builder/attr_bon.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bon/tests/integration/builder/attr_bon.rs b/bon/tests/integration/builder/attr_bon.rs index 48d53e76..9887a2f2 100644 --- a/bon/tests/integration/builder/attr_bon.rs +++ b/bon/tests/integration/builder/attr_bon.rs @@ -103,7 +103,7 @@ fn receiver_variations() { #[builder] fn mut_self_as_pin_mut_self(mut self: Pin<&mut Self>) { - #[allow(clippy::self_assignment, unused_assignments)] + #[allow(clippy::self_assignment, unused_assignments, dead_code)] { self = self; }