public inbox for rust-for-linux@vger.kernel.org
 help / color / mirror / Atom feed
* pin-init Clippy nightly trivial warning in 6.18.y
@ 2026-03-01 18:30 Miguel Ojeda
  2026-03-01 18:39 ` Miguel Ojeda
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Miguel Ojeda @ 2026-03-01 18:30 UTC (permalink / raw)
  To: Benno Lossin, Gary Guo; +Cc: rust-for-linux

Hi Benno, Gary,

With nightly Clippy in 6.18.y, I am seeing a trivial warning, which I
am wondering if we would want to keep enabled or not, i.e. I can see
you may want to keep the `nesting` value check inside like you do in
the nested `match nesting` below that one:

      CLIPPY P rust/libmacros.so - due to command line change
    warning: this `if` can be collapsed into the outer `match`
      --> rust/pin-init/internal/src/helpers.rs:91:17
       |
    91 | /                 if nesting == 1 {
    92 | |                     impl_generics.push(tt.clone());
    93 | |                     impl_generics.push(tt);
    94 | |                     skip_until_comma = false;
    95 | |                 }
       | |_________________^
       |
       = help: for further information visit
https://rust-lang.github.io/rust-clippy/master/index.html#collapsible_match
       = note: `-W clippy::collapsible-match` implied by `-W clippy::all`
       = help: to override `-W clippy::all` add
`#[allow(clippy::collapsible_match)]`
    help: collapse nested if block
       |
    90 ~             TokenTree::Punct(p) if skip_until_comma &&
p.as_char() == ','
    91 ~                 && nesting == 1 => {
    92 |                     impl_generics.push(tt.clone());
    93 |                     impl_generics.push(tt);
    94 |                     skip_until_comma = false;
    95 ~                 }
       |

Anyway, it is just in 6.18.y given the `syn` rewrite and not urgent
since it is nightly.

Please let me know what you think about the warning overall and for
6.18.y we can backport a targeted clean up.

Thanks!

Cheers,
Miguel

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: pin-init Clippy nightly trivial warning in 6.18.y
  2026-03-01 18:30 pin-init Clippy nightly trivial warning in 6.18.y Miguel Ojeda
@ 2026-03-01 18:39 ` Miguel Ojeda
  2026-03-01 19:14 ` Gary Guo
  2026-03-01 20:06 ` Benno Lossin
  2 siblings, 0 replies; 5+ messages in thread
From: Miguel Ojeda @ 2026-03-01 18:39 UTC (permalink / raw)
  To: Benno Lossin, Gary Guo; +Cc: rust-for-linux

On Sun, Mar 1, 2026 at 7:30 PM Miguel Ojeda
<miguel.ojeda.sandonis@gmail.com> wrote:
>
> Anyway, it is just in 6.18.y given the `syn` rewrite and not urgent
> since it is nightly.

And 6.19.y since the rewrite landed in v7.0-rc1.

Cheers,
Miguel

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: pin-init Clippy nightly trivial warning in 6.18.y
  2026-03-01 18:30 pin-init Clippy nightly trivial warning in 6.18.y Miguel Ojeda
  2026-03-01 18:39 ` Miguel Ojeda
@ 2026-03-01 19:14 ` Gary Guo
  2026-03-01 20:06 ` Benno Lossin
  2 siblings, 0 replies; 5+ messages in thread
From: Gary Guo @ 2026-03-01 19:14 UTC (permalink / raw)
  To: Miguel Ojeda, Benno Lossin, Gary Guo; +Cc: rust-for-linux

On Sun Mar 1, 2026 at 6:30 PM GMT, Miguel Ojeda wrote:
> Hi Benno, Gary,
>
> With nightly Clippy in 6.18.y, I am seeing a trivial warning, which I
> am wondering if we would want to keep enabled or not, i.e. I can see
> you may want to keep the `nesting` value check inside like you do in
> the nested `match nesting` below that one:
>
>       CLIPPY P rust/libmacros.so - due to command line change
>     warning: this `if` can be collapsed into the outer `match`
>       --> rust/pin-init/internal/src/helpers.rs:91:17
>        |
>     91 | /                 if nesting == 1 {
>     92 | |                     impl_generics.push(tt.clone());
>     93 | |                     impl_generics.push(tt);
>     94 | |                     skip_until_comma = false;
>     95 | |                 }
>        | |_________________^
>        |
>        = help: for further information visit
> https://rust-lang.github.io/rust-clippy/master/index.html#collapsible_match
>        = note: `-W clippy::collapsible-match` implied by `-W clippy::all`
>        = help: to override `-W clippy::all` add
> `#[allow(clippy::collapsible_match)]`
>     help: collapse nested if block
>        |
>     90 ~             TokenTree::Punct(p) if skip_until_comma &&
> p.as_char() == ','
>     91 ~                 && nesting == 1 => {
>     92 |                     impl_generics.push(tt.clone());
>     93 |                     impl_generics.push(tt);
>     94 |                     skip_until_comma = false;
>     95 ~                 }
>        |
>
> Anyway, it is just in 6.18.y given the `syn` rewrite and not urgent
> since it is nightly.
>
> Please let me know what you think about the warning overall and for
> 6.18.y we can backport a targeted clean up.

I think it reads better without folding the if into the match arm.
`collapsible_if` is a lint that I dislike in general, as nested ifs in many
cases read better. In fact, we already have a `expect(collapsible_if)` in the
codebase.

Best,
Gary

>
> Thanks!
>
> Cheers,
> Miguel


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: pin-init Clippy nightly trivial warning in 6.18.y
  2026-03-01 18:30 pin-init Clippy nightly trivial warning in 6.18.y Miguel Ojeda
  2026-03-01 18:39 ` Miguel Ojeda
  2026-03-01 19:14 ` Gary Guo
@ 2026-03-01 20:06 ` Benno Lossin
  2026-03-01 20:19   ` Miguel Ojeda
  2 siblings, 1 reply; 5+ messages in thread
From: Benno Lossin @ 2026-03-01 20:06 UTC (permalink / raw)
  To: Miguel Ojeda, Gary Guo; +Cc: rust-for-linux

On Sun Mar 1, 2026 at 7:30 PM CET, Miguel Ojeda wrote:
> Hi Benno, Gary,
>
> With nightly Clippy in 6.18.y, I am seeing a trivial warning, which I
> am wondering if we would want to keep enabled or not, i.e. I can see
> you may want to keep the `nesting` value check inside like you do in
> the nested `match nesting` below that one:
>
>       CLIPPY P rust/libmacros.so - due to command line change
>     warning: this `if` can be collapsed into the outer `match`
>       --> rust/pin-init/internal/src/helpers.rs:91:17
>        |
>     91 | /                 if nesting == 1 {
>     92 | |                     impl_generics.push(tt.clone());
>     93 | |                     impl_generics.push(tt);
>     94 | |                     skip_until_comma = false;
>     95 | |                 }
>        | |_________________^
>        |
>        = help: for further information visit
> https://rust-lang.github.io/rust-clippy/master/index.html#collapsible_match
>        = note: `-W clippy::collapsible-match` implied by `-W clippy::all`
>        = help: to override `-W clippy::all` add
> `#[allow(clippy::collapsible_match)]`
>     help: collapse nested if block
>        |
>     90 ~             TokenTree::Punct(p) if skip_until_comma &&
> p.as_char() == ','
>     91 ~                 && nesting == 1 => {
>     92 |                     impl_generics.push(tt.clone());
>     93 |                     impl_generics.push(tt);
>     94 |                     skip_until_comma = false;
>     95 ~                 }
>        |
>
> Anyway, it is just in 6.18.y given the `syn` rewrite and not urgent
> since it is nightly.
>
> Please let me know what you think about the warning overall and for
> 6.18.y we can backport a targeted clean up.

I think we should just allow that lint here. I don't see the need to
shuffle around stable-tree code just to appease a clippy lint. Further,
I agree with Gary that if we were to do the fold, the code would become
harder to read. If we moved the condition into the guard, the pattern
could still "conceptually" match on the blanket arm below (it logically
can't because of the `!skip_until_comma`), but that's a thing that a
human has to parse. So even if we still had this code in mainline, I
would allow the lint there too.

Thanks for keeping the look out for pin-init on the stable trees & Rust
nightly!

Cheers,
Benno

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: pin-init Clippy nightly trivial warning in 6.18.y
  2026-03-01 20:06 ` Benno Lossin
@ 2026-03-01 20:19   ` Miguel Ojeda
  0 siblings, 0 replies; 5+ messages in thread
From: Miguel Ojeda @ 2026-03-01 20:19 UTC (permalink / raw)
  To: Benno Lossin; +Cc: Gary Guo, rust-for-linux

On Sun, Mar 1, 2026 at 8:14 PM Gary Guo <gary@garyguo.net> wrote:
>
> I think it reads better without folding the if into the match arm.
> `collapsible_if` is a lint that I dislike in general, as nested ifs in many
> cases read better. In fact, we already have a `expect(collapsible_if)` in the
> codebase.

On Sun, Mar 1, 2026 at 9:06 PM Benno Lossin <lossin@kernel.org> wrote:
>
> I think we should just allow that lint here. I don't see the need to
> shuffle around stable-tree code just to appease a clippy lint. Further,
> I agree with Gary that if we were to do the fold, the code would become
> harder to read. If we moved the condition into the guard, the pattern
> could still "conceptually" match on the blanket arm below (it logically
> can't because of the `!skip_until_comma`), but that's a thing that a
> human has to parse. So even if we still had this code in mainline, I
> would allow the lint there too.

Thanks both!

I suspected you would both say that, which is also why I asked about
the overall opinions on the lint... :)

I also feel the lint doesn't have much upside -- when the suggestion
may be a good one, it would still read fine when nested anyway. And it
is the kind of lint that may easily bias people to just apply the
suggestion instead of allowing it.

I think we should consider disabling it globally in mainline (and then
we can backport that).

Cheers,
Miguel

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2026-03-01 20:20 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-01 18:30 pin-init Clippy nightly trivial warning in 6.18.y Miguel Ojeda
2026-03-01 18:39 ` Miguel Ojeda
2026-03-01 19:14 ` Gary Guo
2026-03-01 20:06 ` Benno Lossin
2026-03-01 20:19   ` Miguel Ojeda

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox