All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jocelyn Falempe <jfalempe@redhat.com>
To: Miguel Ojeda <miguel.ojeda.sandonis@gmail.com>,
	Miguel Ojeda <ojeda@kernel.org>
Cc: "Javier Martinez Canillas" <javierm@redhat.com>,
	dri-devel@lists.freedesktop.org, rust-for-linux@vger.kernel.org,
	"Boqun Feng" <boqun@kernel.org>, "Gary Guo" <gary@garyguo.net>,
	"Björn Roy Baron" <bjorn3_gh@protonmail.com>,
	"Benno Lossin" <lossin@kernel.org>,
	"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: Re: [PATCH] drm/panic: clean new `clippy::needless_range_loop` lint for Rust 1.100.0
Date: Fri, 4 Sep 2026 00:08:37 +0200	[thread overview]
Message-ID: <101089d2-96ca-4a0a-bea0-6e936beebadb@redhat.com> (raw)
In-Reply-To: <CANiq72=TjVOxDj631gCFMKAeXYbjycmZe74ChXL=rw4H53pQzA@mail.gmail.com>

On 31/08/2026 19:54, Miguel Ojeda wrote:
> On Wed, Aug 26, 2026 at 4:56 PM Miguel Ojeda <ojeda@kernel.org> wrote:
>>
>> Starting with Rust 1.100.0 (expected 2026-11-12), Clippy warns:
>>
>>      warning: the loop variable `i` is only used to index `self.decimals`
>>         --> drivers/gpu/drm/drm_panic_qr.rs:410:18
>>          |
>>      410 |         for i in 0..len {
>>          |                  ^^^^^^
>>          |
>>      note: for this index operation
>>         --> drivers/gpu/drm/drm_panic_qr.rs:411:13
>>          |
>>      411 |             self.decimals[i] = (chunk % 10) as u8;
>>          |             ^^^^^^^^^^^^^^^^
>>          = help: for further information visit https://rust-lang.github.io/rust-clippy/main/index.html#needless_range_loop
>>          = note: `-W clippy::needless-range-loop` implied by `-W clippy::all`
>>          = help: to override `-W clippy::all` add `#[allow(clippy::needless_range_loop)]`
>>      help: consider using an iterator
>>          |
>>      410 -         for i in 0..len {
>>      410 +         for <item> in self.decimals.iter_mut().take(len) {
>>          |
>>
>> The lint did not trigger here before because it could not handle arrays
>> behind a field access such as `self.decimals` -- Clippy was improved to
>> catch those cases [1][2].
>>
>> Thus clean the warning by iterating over a slice rather than using
>> `take()` so that an out-of-range `len` still triggers the same bounds
>> check as the indexed loop.
>>
>> Cc: stable@vger.kernel.org # Needed in 6.18.y and later.
>> Link: https://github.com/rust-lang/rust-clippy/issues/16631 [1]
>> Link: https://github.com/rust-lang/rust-clippy/pull/16634 [2]
>> Assisted-by: LLM
>> Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
>> ---
>> One may want to keep the loop in a shape similar to e.g. the one above,
>> though.
> 
> Jocelyn: I will likely send another rust-fixes PR during this cycle,
> so I can put this one there if you agree with it.

Sorry for replying late.
That looks good to me, and you can take this patch in the rust-fixes tree.

Reviewed-by: Jocelyn Falempe <jfalempe@redhat.com>
> 
> Thanks!
> 
> Cheers,
> Miguel
> 


  reply	other threads:[~2026-09-03 22:08 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-26 14:56 [PATCH] drm/panic: clean new `clippy::needless_range_loop` lint for Rust 1.100.0 Miguel Ojeda
2026-08-27  1:36 ` Alexandre Courbot
2026-08-31 17:54 ` Miguel Ojeda
2026-09-03 22:08   ` Jocelyn Falempe [this message]
2026-09-03 22: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=101089d2-96ca-4a0a-bea0-6e936beebadb@redhat.com \
    --to=jfalempe@redhat.com \
    --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=dri-devel@lists.freedesktop.org \
    --cc=gary@garyguo.net \
    --cc=javierm@redhat.com \
    --cc=lossin@kernel.org \
    --cc=miguel.ojeda.sandonis@gmail.com \
    --cc=ojeda@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.