From: "Gary Guo" <gary@garyguo.net>
To: <peder.bergan@gmail.com>, "Tamir Duberstein" <tamird@kernel.org>,
"Andreas Hindborg" <a.hindborg@kernel.org>,
"Miguel Ojeda" <ojeda@kernel.org>
Cc: "Boqun Feng" <boqun@kernel.org>, "Gary Guo" <gary@garyguo.net>,
"Björn Roy Baron" <bjorn3_gh@protonmail.com>,
"Benno Lossin" <lossin@kernel.org>,
"Alice Ryhl" <aliceryhl@google.com>,
"Trevor Gross" <tmgross@umich.edu>,
"Danilo Krummrich" <dakr@kernel.org>,
"Daniel Almeida" <daniel.almeida@collabora.com>,
"Alexandre Courbot" <acourbot@nvidia.com>,
"Onur Özkan" <work@onurozkan.dev>,
rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org,
"Jesung Yang" <y.j3ms.n@gmail.com>
Subject: Re: [PATCH] rust: xarray: capture the iterator lifetime explicitly
Date: Wed, 18 Nov 2026 10:45:17 +0000 [thread overview]
Message-ID: <DMY9XV1M1YKE.1FXRA27UM619K@garyguo.net> (raw)
In-Reply-To: <20261118-cleanup-xarray-precise-capture-v1-1-43e148eadea4@gmail.com>
On Wed Nov 18, 2026 at 10:39 AM GMT, Peder Bergan via B4 Relay wrote:
> From: Peder Bergan <peder.bergan@gmail.com>
>
> XArray::iter uses an outlives bound to capture the lifetime of the
> borrow of self in the returned iterator. Its caller consumes the
> iterator during pinned drop and does not need an outlives guarantee.
>
> Use a precise capturing bound to name the borrowed lifetime. Also
> include T, since the bound must list all in-scope type parameters.
>
> Suggested-by: Jesung Yang <y.j3ms.n@gmail.com>
> Link: https://github.com/Rust-for-Linux/linux/issues/1175
> Signed-off-by: Peder Bergan <peder.bergan@gmail.com>
> ---
> The XArray KUnit doctest passed on x86-64 QEMU. The Rust kernel
> crate built with CLIPPY=1.
>
> OpenAI Codex assisted with the signature changes, testing and
> drafting this commit message.
None of this is relevant when we upgrade to Rust 2024, I'd avoid the additional
churn and only do this where needed.
Best,
Gary
> ---
> rust/kernel/xarray.rs | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/rust/kernel/xarray.rs b/rust/kernel/xarray.rs
> index 987c9c0c2198..4a67e7f24335 100644
> --- a/rust/kernel/xarray.rs
> +++ b/rust/kernel/xarray.rs
> @@ -108,7 +108,7 @@ pub fn new(kind: AllocKind) -> impl PinInit<Self> {
> })
> }
>
> - fn iter(&self) -> impl Iterator<Item = NonNull<c_void>> + '_ {
> + fn iter(&self) -> impl Iterator<Item = NonNull<c_void>> + use<'_, T> {
> let mut index = 0;
>
> // SAFETY: `self.xa` is always valid by the type invariant.
>
> ---
> base-commit: aebb7274476403040d582c61478df8f4a7bf9cd3
> change-id: 20261118-cleanup-xarray-precise-capture-1bf06165c6cf
>
> Best regards,
> --
> Peder Bergan <peder.bergan@gmail.com>
prev parent reply other threads:[~2026-11-18 10:45 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-18 10:39 Peder Bergan via B4 Relay
2026-11-18 10:45 ` Gary Guo [this message]
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=DMY9XV1M1YKE.1FXRA27UM619K@garyguo.net \
--to=gary@garyguo.net \
--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=linux-kernel@vger.kernel.org \
--cc=lossin@kernel.org \
--cc=ojeda@kernel.org \
--cc=peder.bergan@gmail.com \
--cc=rust-for-linux@vger.kernel.org \
--cc=tamird@kernel.org \
--cc=tmgross@umich.edu \
--cc=work@onurozkan.dev \
--cc=y.j3ms.n@gmail.com \
/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
all inboxes | Powered by JetHome®