* Re: [PATCH] rust: cpufreq: clean new `clippy::map_or_identity` lint for Rust 1.98.0
2026-05-30 9:58 [PATCH] rust: cpufreq: clean new `clippy::map_or_identity` lint for Rust 1.98.0 Miguel Ojeda
@ 2026-05-30 10:29 ` Alexandre Courbot
2026-05-30 11:04 ` Gary Guo
` (4 subsequent siblings)
5 siblings, 0 replies; 8+ messages in thread
From: Alexandre Courbot @ 2026-05-30 10:29 UTC (permalink / raw)
To: Miguel Ojeda
Cc: Rafael J. Wysocki, Viresh Kumar, linux-pm, Boqun Feng, Gary Guo,
Björn Roy Baron, Benno Lossin, Andreas Hindborg, Alice Ryhl,
Trevor Gross, Danilo Krummrich, rust-for-linux, stable
On Sat May 30, 2026 at 6:58 PM JST, Miguel Ojeda wrote:
> Starting with Rust 1.98.0 (expected 2026-08-20), Clippy is likely
> introducing a new lint `clippy::map_or_identity` [1][2], which currently
> triggers in a single case:
>
> warning: expression can be simplified using `Result::unwrap_or()`
> --> rust/kernel/cpufreq.rs:1326:60
> |
> 1326 | PolicyCpu::from_cpu(cpu_id).map_or(0, |mut policy| T::get(&mut policy).map_or(0, |f| f))
> | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> |
> = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#map_or_identity
> = note: `-W clippy::map-or-identity` implied by `-W clippy::all`
> = help: to override `-W clippy::all` add `#[allow(clippy::map_or_identity)]`
> help: consider using `unwrap_or`
> |
> 1326 - PolicyCpu::from_cpu(cpu_id).map_or(0, |mut policy| T::get(&mut policy).map_or(0, |f| f))
> 1326 + PolicyCpu::from_cpu(cpu_id).map_or(0, |mut policy| T::get(&mut policy).unwrap_or(0))
> |
>
> The suggestion is valid, thus clean it up.
>
> Cc: stable@vger.kernel.org # Needed in 6.12.y and later (Rust is pinned in older LTSs).
> Link: https://github.com/rust-lang/rust-clippy/issues/15801 [1]
> Link: https://github.com/rust-lang/rust-clippy/pull/16052 [2]
> Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
Reviewed-by: Alexandre Courbot <acourbot@nvidia.com>
^ permalink raw reply [flat|nested] 8+ messages in thread* Re: [PATCH] rust: cpufreq: clean new `clippy::map_or_identity` lint for Rust 1.98.0
2026-05-30 9:58 [PATCH] rust: cpufreq: clean new `clippy::map_or_identity` lint for Rust 1.98.0 Miguel Ojeda
2026-05-30 10:29 ` Alexandre Courbot
@ 2026-05-30 11:04 ` Gary Guo
2026-05-30 11:34 ` Miguel Ojeda
` (3 subsequent siblings)
5 siblings, 0 replies; 8+ messages in thread
From: Gary Guo @ 2026-05-30 11:04 UTC (permalink / raw)
To: Miguel Ojeda, Rafael J. Wysocki, Viresh Kumar
Cc: linux-pm, Boqun Feng, Gary Guo, Björn Roy Baron,
Benno Lossin, Andreas Hindborg, Alice Ryhl, Trevor Gross,
Danilo Krummrich, rust-for-linux, stable
On Sat May 30, 2026 at 10:58 AM BST, Miguel Ojeda wrote:
> Starting with Rust 1.98.0 (expected 2026-08-20), Clippy is likely
> introducing a new lint `clippy::map_or_identity` [1][2], which currently
> triggers in a single case:
>
> warning: expression can be simplified using `Result::unwrap_or()`
> --> rust/kernel/cpufreq.rs:1326:60
> |
> 1326 | PolicyCpu::from_cpu(cpu_id).map_or(0, |mut policy| T::get(&mut policy).map_or(0, |f| f))
> | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> |
> = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#map_or_identity
> = note: `-W clippy::map-or-identity` implied by `-W clippy::all`
> = help: to override `-W clippy::all` add `#[allow(clippy::map_or_identity)]`
> help: consider using `unwrap_or`
> |
> 1326 - PolicyCpu::from_cpu(cpu_id).map_or(0, |mut policy| T::get(&mut policy).map_or(0, |f| f))
> 1326 + PolicyCpu::from_cpu(cpu_id).map_or(0, |mut policy| T::get(&mut policy).unwrap_or(0))
> |
>
> The suggestion is valid, thus clean it up.
>
> Cc: stable@vger.kernel.org # Needed in 6.12.y and later (Rust is pinned in older LTSs).
> Link: https://github.com/rust-lang/rust-clippy/issues/15801 [1]
> Link: https://github.com/rust-lang/rust-clippy/pull/16052 [2]
> Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
Reviewed-by: Gary Guo <gary@garyguo.net>
> ---
> rust/kernel/cpufreq.rs | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
^ permalink raw reply [flat|nested] 8+ messages in thread* Re: [PATCH] rust: cpufreq: clean new `clippy::map_or_identity` lint for Rust 1.98.0
2026-05-30 9:58 [PATCH] rust: cpufreq: clean new `clippy::map_or_identity` lint for Rust 1.98.0 Miguel Ojeda
2026-05-30 10:29 ` Alexandre Courbot
2026-05-30 11:04 ` Gary Guo
@ 2026-05-30 11:34 ` Miguel Ojeda
2026-06-01 5:27 ` Viresh Kumar
2026-05-30 13:40 ` Zhongqiu Han
` (2 subsequent siblings)
5 siblings, 1 reply; 8+ messages in thread
From: Miguel Ojeda @ 2026-05-30 11:34 UTC (permalink / raw)
To: Miguel Ojeda
Cc: Rafael J. Wysocki, Viresh Kumar, linux-pm, Boqun Feng, Gary Guo,
Björn Roy Baron, Benno Lossin, Andreas Hindborg, Alice Ryhl,
Trevor Gross, Danilo Krummrich, rust-for-linux, stable
On Sat, May 30, 2026 at 11:58 AM Miguel Ojeda <ojeda@kernel.org> wrote:
>
> Starting with Rust 1.98.0 (expected 2026-08-20), Clippy is likely
> introducing a new lint `clippy::map_or_identity` [1][2], which currently
> triggers in a single case:
>
> warning: expression can be simplified using `Result::unwrap_or()`
> --> rust/kernel/cpufreq.rs:1326:60
> |
> 1326 | PolicyCpu::from_cpu(cpu_id).map_or(0, |mut policy| T::get(&mut policy).map_or(0, |f| f))
> | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> |
> = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#map_or_identity
> = note: `-W clippy::map-or-identity` implied by `-W clippy::all`
> = help: to override `-W clippy::all` add `#[allow(clippy::map_or_identity)]`
> help: consider using `unwrap_or`
> |
> 1326 - PolicyCpu::from_cpu(cpu_id).map_or(0, |mut policy| T::get(&mut policy).map_or(0, |f| f))
> 1326 + PolicyCpu::from_cpu(cpu_id).map_or(0, |mut policy| T::get(&mut policy).unwrap_or(0))
> |
>
> The suggestion is valid, thus clean it up.
>
> Cc: stable@vger.kernel.org # Needed in 6.12.y and later (Rust is pinned in older LTSs).
> Link: https://github.com/rust-lang/rust-clippy/issues/15801 [1]
> Link: https://github.com/rust-lang/rust-clippy/pull/16052 [2]
> Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
Viresh, Rafael: I can put this into `rust-next` if you prefer (I
considered `rust-fixes`, but it is not important enough at this
stage).
Cheers,
Miguel
^ permalink raw reply [flat|nested] 8+ messages in thread* Re: [PATCH] rust: cpufreq: clean new `clippy::map_or_identity` lint for Rust 1.98.0
2026-05-30 11:34 ` Miguel Ojeda
@ 2026-06-01 5:27 ` Viresh Kumar
0 siblings, 0 replies; 8+ messages in thread
From: Viresh Kumar @ 2026-06-01 5:27 UTC (permalink / raw)
To: Miguel Ojeda
Cc: Miguel Ojeda, Rafael J. Wysocki, linux-pm, Boqun Feng, Gary Guo,
Björn Roy Baron, Benno Lossin, Andreas Hindborg, Alice Ryhl,
Trevor Gross, Danilo Krummrich, rust-for-linux, stable
On 30-05-26, 13:34, Miguel Ojeda wrote:
> On Sat, May 30, 2026 at 11:58 AM Miguel Ojeda <ojeda@kernel.org> wrote:
> >
> > Starting with Rust 1.98.0 (expected 2026-08-20), Clippy is likely
> > introducing a new lint `clippy::map_or_identity` [1][2], which currently
> > triggers in a single case:
> >
> > warning: expression can be simplified using `Result::unwrap_or()`
> > --> rust/kernel/cpufreq.rs:1326:60
> > |
> > 1326 | PolicyCpu::from_cpu(cpu_id).map_or(0, |mut policy| T::get(&mut policy).map_or(0, |f| f))
> > | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> > |
> > = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#map_or_identity
> > = note: `-W clippy::map-or-identity` implied by `-W clippy::all`
> > = help: to override `-W clippy::all` add `#[allow(clippy::map_or_identity)]`
> > help: consider using `unwrap_or`
> > |
> > 1326 - PolicyCpu::from_cpu(cpu_id).map_or(0, |mut policy| T::get(&mut policy).map_or(0, |f| f))
> > 1326 + PolicyCpu::from_cpu(cpu_id).map_or(0, |mut policy| T::get(&mut policy).unwrap_or(0))
> > |
> >
> > The suggestion is valid, thus clean it up.
> >
> > Cc: stable@vger.kernel.org # Needed in 6.12.y and later (Rust is pinned in older LTSs).
> > Link: https://github.com/rust-lang/rust-clippy/issues/15801 [1]
> > Link: https://github.com/rust-lang/rust-clippy/pull/16052 [2]
> > Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
>
> Viresh, Rafael: I can put this into `rust-next` if you prefer (I
> considered `rust-fixes`, but it is not important enough at this
> stage).
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
--
viresh
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] rust: cpufreq: clean new `clippy::map_or_identity` lint for Rust 1.98.0
2026-05-30 9:58 [PATCH] rust: cpufreq: clean new `clippy::map_or_identity` lint for Rust 1.98.0 Miguel Ojeda
` (2 preceding siblings ...)
2026-05-30 11:34 ` Miguel Ojeda
@ 2026-05-30 13:40 ` Zhongqiu Han
2026-06-01 6:22 ` Miguel Ojeda
2026-06-01 6:30 ` Miguel Ojeda
5 siblings, 0 replies; 8+ messages in thread
From: Zhongqiu Han @ 2026-05-30 13:40 UTC (permalink / raw)
To: Miguel Ojeda, Rafael J. Wysocki, Viresh Kumar
Cc: linux-pm, Boqun Feng, Gary Guo, Björn Roy Baron,
Benno Lossin, Andreas Hindborg, Alice Ryhl, Trevor Gross,
Danilo Krummrich, rust-for-linux, stable, zhongqiu.han
On 5/30/2026 5:58 PM, Miguel Ojeda wrote:
> Starting with Rust 1.98.0 (expected 2026-08-20), Clippy is likely
> introducing a new lint `clippy::map_or_identity` [1][2], which currently
> triggers in a single case:
>
> warning: expression can be simplified using `Result::unwrap_or()`
> --> rust/kernel/cpufreq.rs:1326:60
> |
> 1326 | PolicyCpu::from_cpu(cpu_id).map_or(0, |mut policy| T::get(&mut policy).map_or(0, |f| f))
> | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> |
> = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#map_or_identity
> = note: `-W clippy::map-or-identity` implied by `-W clippy::all`
> = help: to override `-W clippy::all` add `#[allow(clippy::map_or_identity)]`
> help: consider using `unwrap_or`
> |
> 1326 - PolicyCpu::from_cpu(cpu_id).map_or(0, |mut policy| T::get(&mut policy).map_or(0, |f| f))
> 1326 + PolicyCpu::from_cpu(cpu_id).map_or(0, |mut policy| T::get(&mut policy).unwrap_or(0))
> |
>
> The suggestion is valid, thus clean it up.
>
> Cc: stable@vger.kernel.org # Needed in 6.12.y and later (Rust is pinned in older LTSs).
> Link: https://github.com/rust-lang/rust-clippy/issues/15801 [1]
> Link: https://github.com/rust-lang/rust-clippy/pull/16052 [2]
> Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
Reviewed-by: Zhongqiu Han <zhongqiu.han@oss.qualcomm.com>
> ---
> rust/kernel/cpufreq.rs | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/rust/kernel/cpufreq.rs b/rust/kernel/cpufreq.rs
> index d8d26870bea2..a20bd5006f38 100644
> --- a/rust/kernel/cpufreq.rs
> +++ b/rust/kernel/cpufreq.rs
> @@ -1323,7 +1323,7 @@ impl<T: Driver> Registration<T> {
> // SAFETY: The C API guarantees that `cpu` refers to a valid CPU number.
> let cpu_id = unsafe { CpuId::from_u32_unchecked(cpu) };
>
> - PolicyCpu::from_cpu(cpu_id).map_or(0, |mut policy| T::get(&mut policy).map_or(0, |f| f))
> + PolicyCpu::from_cpu(cpu_id).map_or(0, |mut policy| T::get(&mut policy).unwrap_or(0))
> }
>
> /// Driver's `update_limit` callback.
>
> base-commit: 420dd187e1572bb7e232781bc4377a80c8eb64fb
--
Thx and BRs,
Zhongqiu Han
^ permalink raw reply [flat|nested] 8+ messages in thread* Re: [PATCH] rust: cpufreq: clean new `clippy::map_or_identity` lint for Rust 1.98.0
2026-05-30 9:58 [PATCH] rust: cpufreq: clean new `clippy::map_or_identity` lint for Rust 1.98.0 Miguel Ojeda
` (3 preceding siblings ...)
2026-05-30 13:40 ` Zhongqiu Han
@ 2026-06-01 6:22 ` Miguel Ojeda
2026-06-01 6:30 ` Miguel Ojeda
5 siblings, 0 replies; 8+ messages in thread
From: Miguel Ojeda @ 2026-06-01 6:22 UTC (permalink / raw)
To: Miguel Ojeda
Cc: Rafael J. Wysocki, Viresh Kumar, linux-pm, Boqun Feng, Gary Guo,
Björn Roy Baron, Benno Lossin, Andreas Hindborg, Alice Ryhl,
Trevor Gross, Danilo Krummrich, rust-for-linux, stable
On Sat, May 30, 2026 at 11:58 AM Miguel Ojeda <ojeda@kernel.org> wrote:
>
> Starting with Rust 1.98.0 (expected 2026-08-20), Clippy is likely
> introducing a new lint `clippy::map_or_identity` [1][2], which currently
> triggers in a single case:
>
> warning: expression can be simplified using `Result::unwrap_or()`
> --> rust/kernel/cpufreq.rs:1326:60
> |
> 1326 | PolicyCpu::from_cpu(cpu_id).map_or(0, |mut policy| T::get(&mut policy).map_or(0, |f| f))
> | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> |
> = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#map_or_identity
> = note: `-W clippy::map-or-identity` implied by `-W clippy::all`
> = help: to override `-W clippy::all` add `#[allow(clippy::map_or_identity)]`
> help: consider using `unwrap_or`
> |
> 1326 - PolicyCpu::from_cpu(cpu_id).map_or(0, |mut policy| T::get(&mut policy).map_or(0, |f| f))
> 1326 + PolicyCpu::from_cpu(cpu_id).map_or(0, |mut policy| T::get(&mut policy).unwrap_or(0))
> |
>
> The suggestion is valid, thus clean it up.
>
> Cc: stable@vger.kernel.org # Needed in 6.12.y and later (Rust is pinned in older LTSs).
> Link: https://github.com/rust-lang/rust-clippy/issues/15801 [1]
> Link: https://github.com/rust-lang/rust-clippy/pull/16052 [2]
> Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
Applied to `rust-next` -- thanks everyone!
Cheers,
Miguel
^ permalink raw reply [flat|nested] 8+ messages in thread* Re: [PATCH] rust: cpufreq: clean new `clippy::map_or_identity` lint for Rust 1.98.0
2026-05-30 9:58 [PATCH] rust: cpufreq: clean new `clippy::map_or_identity` lint for Rust 1.98.0 Miguel Ojeda
` (4 preceding siblings ...)
2026-06-01 6:22 ` Miguel Ojeda
@ 2026-06-01 6:30 ` Miguel Ojeda
5 siblings, 0 replies; 8+ messages in thread
From: Miguel Ojeda @ 2026-06-01 6:30 UTC (permalink / raw)
To: Miguel Ojeda
Cc: Rafael J. Wysocki, Viresh Kumar, linux-pm, Boqun Feng, Gary Guo,
Björn Roy Baron, Benno Lossin, Andreas Hindborg, Alice Ryhl,
Trevor Gross, Danilo Krummrich, rust-for-linux, stable
On Sat, May 30, 2026 at 11:58 AM Miguel Ojeda <ojeda@kernel.org> wrote:
>
> Cc: stable@vger.kernel.org # Needed in 6.12.y and later (Rust is pinned in older LTSs).
Adjusted to "6.18.y and later", since `cpufreq` was not there in 6.12.y anyway.
(I didn't use Fixes: because it isn't really a fix, although as usual
it depends on how one thinks about those...)
Cheers,
Miguel
^ permalink raw reply [flat|nested] 8+ messages in thread