From dea4872fe5602ccd84041284d5a7c67c20a44406 Mon Sep 17 00:00:00 2001 From: Gary Guo Date: Tue, 17 Nov 2026 13:07:59 +0000 Subject: [PATCH] internal: allow `clippy::large_unopt_stack_frames` Since Rust 1.102, Clippy renames `large_stack_frames` to `large_unopt_stack_frames` and make it warn by default. This is a good thing as in such cases pin-init should be used rather than potentially leave unoptimized large moves on stack. However, this also triggers in unexecutable code paths that pin-init generates for field duplication and exhaustiveness checks. Allow it on the generated check closure. Signed-off-by: Gary Guo --- internal/src/init.rs | 2 +- tests/ui/expand/simple-init.expanded.rs | 2 +- tests/ui/expand/tuple_struct.expanded.rs | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/internal/src/init.rs b/internal/src/init.rs index ded2b528..c78f8d3c 100644 --- a/internal/src/init.rs +++ b/internal/src/init.rs @@ -572,7 +572,7 @@ fn make_field_check( }; quote_spanned! { Span::mixed_site() => - #[allow(unreachable_code)] + #[allow(unreachable_code, clippy::large_unopt_stack_frames)] // We use unreachable code to perform field checks. They're still checked by the compiler. // SAFETY: this code is never executed. let _ = || unsafe { diff --git a/tests/ui/expand/simple-init.expanded.rs b/tests/ui/expand/simple-init.expanded.rs index c90efb08..95bc00b0 100644 --- a/tests/ui/expand/simple-init.expanded.rs +++ b/tests/ui/expand/simple-init.expanded.rs @@ -12,7 +12,7 @@ fn main() { ::core::convert::Infallible, >(move |slot, data_lt| { if true {} else {} - #[allow(unreachable_code)] + #[allow(unreachable_code, clippy::large_unopt_stack_frames)] let _ = || unsafe { ::core::ptr::write(slot, Foo {}) }; Ok(unsafe { ::pin_init::__internal::InitOk::new() }) }); diff --git a/tests/ui/expand/tuple_struct.expanded.rs b/tests/ui/expand/tuple_struct.expanded.rs index 4e51e04f..071047f8 100644 --- a/tests/ui/expand/tuple_struct.expanded.rs +++ b/tests/ui/expand/tuple_struct.expanded.rs @@ -286,7 +286,7 @@ fn main() { ::core::mem::forget(___1_guard); ::core::mem::forget(___0_guard); } - #[allow(unreachable_code)] + #[allow(unreachable_code, clippy::large_unopt_stack_frames)] let _ = || unsafe { let _ = &(*slot).0; let _ = &(*slot).1; @@ -371,7 +371,7 @@ fn main() { ::core::mem::forget(___1_guard); ::core::mem::forget(___0_guard); } - #[allow(unreachable_code)] + #[allow(unreachable_code, clippy::large_unopt_stack_frames)] let _ = || unsafe { let _ = &(*slot).0; let _ = &(*slot).1;