rust-for-linux.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Benno Lossin <benno.lossin@proton.me>
To: Miguel Ojeda <ojeda@kernel.org>, Alex Gaynor <alex.gaynor@gmail.com>
Cc: "Boqun Feng" <boqun.feng@gmail.com>,
	"Gary Guo" <gary@garyguo.net>,
	"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>,
	rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org,
	patches@lists.linux.dev
Subject: Re: [PATCH] rust: clean Rust 1.86.0 new `clippy::needless_continue` cases
Date: Tue, 01 Apr 2025 23:53:05 +0000	[thread overview]
Message-ID: <D8VPGBN60E61.1Z48FQW6TL3A@proton.me> (raw)
In-Reply-To: <20250401221205.52381-1-ojeda@kernel.org>

On Wed Apr 2, 2025 at 12:12 AM CEST, Miguel Ojeda wrote:
> Starting with the upcoming Rust 1.86.0, Clippy's `needless_continue` lint
> complains about the last statement of a loop [1], including cases like:
>
>     while ... {
>         match ... {
>             ... if ... => {
>                 ...
>                 return ...;
>             }
>             _ => continue,
>         }
>     }
>
> as well as nested `match`es in a loop.
>
> Thus clean them up.
>
> Link: https://github.com/rust-lang/rust-clippy/pull/13891 [1]
> Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
> ---
> To be honest, I am not sure we want this.
>
> The lint can find cases that should be simplified, and it has been a nice lint
> so far, but somehow I feel that using `continue` shows the intent better when
> it is alone in an arm like that, and I am not sure we want to force people to
> try to find other ways to write the code either, in cases when that applies.
>
> If others feel this reads worse, then I would be happy to disable the lint and
> open an issue upstream to keep the cases that are more clear cut.

I'm not too sure about this change, if the loop is longer than one
screen, it makes a lot of sense to have a `continue` instead of `()`,
since one might not see that there is nothing after the `match`.

I also think that an explicit `continue` is nicer from a expressability
standpoint. So I think we should keep them.

---
Cheers,
Benno

>  rust/macros/helpers.rs | 2 +-
>  rust/macros/kunit.rs   | 2 +-
>  2 files changed, 2 insertions(+), 2 deletions(-)


  reply	other threads:[~2025-04-01 23:53 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-01 22:12 [PATCH] rust: clean Rust 1.86.0 new `clippy::needless_continue` cases Miguel Ojeda
2025-04-01 23:53 ` Benno Lossin [this message]
2025-04-02 11:13   ` Miguel Ojeda
2025-04-02 13:58     ` Tamir Duberstein
2025-04-02 15:27       ` Miguel Ojeda
2025-04-02 16:41         ` Tamir Duberstein
2025-04-02 20:29           ` Miguel Ojeda
2025-04-02 21:08             ` Tamir Duberstein
2025-04-03 17:35               ` Miguel Ojeda
2025-04-02  9:18 ` Danilo Krummrich
2025-04-02 10:55   ` Miguel Ojeda

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=D8VPGBN60E61.1Z48FQW6TL3A@proton.me \
    --to=benno.lossin@proton.me \
    --cc=a.hindborg@kernel.org \
    --cc=alex.gaynor@gmail.com \
    --cc=aliceryhl@google.com \
    --cc=bjorn3_gh@protonmail.com \
    --cc=boqun.feng@gmail.com \
    --cc=dakr@kernel.org \
    --cc=gary@garyguo.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=ojeda@kernel.org \
    --cc=patches@lists.linux.dev \
    --cc=rust-for-linux@vger.kernel.org \
    --cc=tmgross@umich.edu \
    /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;
as well as URLs for NNTP newsgroup(s).