* [PATCH] rust: init: clean Rust 1.102.0's `clippy::large_unopt_stack_frames` lint
@ 2026-11-26 13:14 Miguel Ojeda
0 siblings, 0 replies; only message in thread
From: Miguel Ojeda @ 2026-11-26 13:14 UTC (permalink / raw)
To: Benno Lossin, Gary Guo, Miguel Ojeda
Cc: rust-for-linux, Boqun Feng, Björn Roy Baron,
Andreas Hindborg, Alice Ryhl, Trevor Gross, Danilo Krummrich,
Daniel Almeida, Tamir Duberstein, Alexandre Courbot,
Onur Özkan, stable
Starting with Rust 1.102.0 (expected 2027-02-04), Clippy renames the
`large_stack_frames` lint to `large_unopt_stack_frames` and moves it to
`suspicious` from `nursery` [1], and thus we start to see it in the
examples of `try_init!` and `try_pin_init!`:
warning: closure generated by this macro may allocate a lot of stack space
--> rust/doctests_kernel_generated.rs:6716:9
|
6716 | / try_init!(Self {
6717 | | big: KBox::init(init_zeroed(), GFP_KERNEL)?,
6718 | | small: [0; 1024 * 1024],
6719 | | }? Error)
| |_________________^
|
= help: for further information visit https://clippy.rust-lang.org/main/index.html#large_unopt_stack_frames
= note: `-W clippy::large-unopt-stack-frames` implied by `-W clippy::all`
= help: to override `-W clippy::all` add `#[allow(clippy::large_unopt_stack_frames)]`
The 1 MiB array is initialized by value, thus the closure that is
generated would need to hold it in its stack frame (without optimizations,
which is what the lint goes by).
Thus initialize it in place instead.
Note that the warning only goes away together with commit 5a2024c03eb6
("rust: pin-init: internal: allow `clippy::large_unopt_stack_frames`").
Cc: stable@vger.kernel.org # 6.12.x (Rust is pinned in older LTSs)
Link: https://github.com/rust-lang/rust-clippy/pull/17749 [1]
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
---
rust/kernel/init.rs | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/rust/kernel/init.rs b/rust/kernel/init.rs
index 1fdc3963e3e3..238ebb3b1a71 100644
--- a/rust/kernel/init.rs
+++ b/rust/kernel/init.rs
@@ -211,7 +211,7 @@ fn init<E>(init: impl Init<T, E>, flags: Flags) -> error::Result<Self>
/// fn new() -> impl Init<Self, Error> {
/// try_init!(Self {
/// big: KBox::init(init_zeroed(), GFP_KERNEL)?,
-/// small: [0; 1024 * 1024],
+/// small <- init_zeroed(),
/// }? Error)
/// }
/// }
@@ -263,7 +263,7 @@ macro_rules! try_init {
/// fn new() -> impl PinInit<Self, Error> {
/// try_pin_init!(Self {
/// big: KBox::init(init_zeroed(), GFP_KERNEL)?,
-/// small: [0; 1024 * 1024],
+/// small <- init_zeroed(),
/// ptr: core::ptr::null_mut(),
/// }? Error)
/// }
base-commit: b6a9fa34ce4187cb69d3c588a4bbffc31ce5db8f
--
2.56.0
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2026-11-26 13:15 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-26 13:14 [PATCH] rust: init: clean Rust 1.102.0's `clippy::large_unopt_stack_frames` lint Miguel Ojeda
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox