From: Miguel Ojeda <ojeda@kernel.org>
To: Benno Lossin <lossin@kernel.org>, Gary Guo <gary@garyguo.net>,
Miguel Ojeda <ojeda@kernel.org>
Cc: rust-for-linux@vger.kernel.org, "Boqun Feng" <boqun@kernel.org>,
"Björn Roy Baron" <bjorn3_gh@protonmail.com>,
"Andreas Hindborg" <a.hindborg@kernel.org>,
"Alice Ryhl" <aliceryhl@google.com>,
"Trevor Gross" <tmgross@umich.edu>,
"Danilo Krummrich" <dakr@kernel.org>,
"Daniel Almeida" <daniel.almeida@collabora.com>,
"Tamir Duberstein" <tamird@kernel.org>,
"Alexandre Courbot" <acourbot@nvidia.com>,
"Onur Özkan" <work@onurozkan.dev>,
stable@vger.kernel.org
Subject: [PATCH] rust: init: clean Rust 1.102.0's `clippy::large_unopt_stack_frames` lint
Date: Thu, 26 Nov 2026 14:14:56 +0100 [thread overview]
Message-ID: <20261126131456.87524-1-ojeda@kernel.org> (raw)
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
reply other threads:[~2026-11-26 13:15 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261126131456.87524-1-ojeda@kernel.org \
--to=ojeda@kernel.org \
--cc=a.hindborg@kernel.org \
--cc=acourbot@nvidia.com \
--cc=aliceryhl@google.com \
--cc=bjorn3_gh@protonmail.com \
--cc=boqun@kernel.org \
--cc=dakr@kernel.org \
--cc=daniel.almeida@collabora.com \
--cc=gary@garyguo.net \
--cc=lossin@kernel.org \
--cc=rust-for-linux@vger.kernel.org \
--cc=stable@vger.kernel.org \
--cc=tamird@kernel.org \
--cc=tmgross@umich.edu \
--cc=work@onurozkan.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox