Re: [PATCH v2] rust: allow `clippy::unwrap_or_default` globally
Miguel Ojeda <[email protected]> Thu, 9 Jul 2026 23:51:59 +0200
| Newsgroups | gmane.linux.kernel.rust,gmane.linux.kernel,gmane.linux.kbuild.devel |
|---|---|
| Message-ID | <CANiq72mBdo3nOJffN4LJe6XS1Sm3qkLvM8MdnS5Q61=0UiE9_g@mail.gmail.com> |
On Wed, Jul 8, 2026 at 12:49 PM Alexandre Courbot <[email protected]> wrote: > > Starting with rustc 1.88, the `clippy::unwrap_or_default` lint triggers > on `rust/kernel/soc.rs` if `CONFIG_CC_OPTIMIZE_FOR_SIZE=y`: > > warning: use of `unwrap_or` to construct default value > --> ../rust/kernel/soc.rs:66:10 > | > 66 | .unwrap_or(core::ptr::null()) > | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `unwrap_or_default()` > > This is a clippy bug [1]: the lint decides whether an expression is > equivalent to `Default::default()` by inspecting the optimized MIR of > `<*const T as Default>::default` exported by `core`, so its outcome > depends on the optimization level `core` was built with. Moreover, its > suggestion ignores our MSRV of 1.85 (`Default` for `*const T` is only > stable since Rust 1.88), so we could not apply it anyway. > > Disable the lint globally rather than working around this single > occurrence; it can be re-enabled conditionally using `rustc-min-version` > once clippy is fixed. > > Link: https://github.com/rust-lang/rust-clippy/issues/17379 [1] > Suggested-by: Miguel Ojeda <[email protected]> > Signed-off-by: Alexandre Courbot <[email protected]> Applied to `rust-fixes` -- thanks! Cc: [email protected] # Needed in 6.12.y and later (Rust is pinned in older LTSs). [ Moved to non-versioned group. - Miguel ] Cheers, Miguel