All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] rust: xarray: capture the iterator lifetime explicitly
@ 2026-11-18 10:39 ` Peder Bergan via B4 Relay
  0 siblings, 0 replies; 3+ messages in thread
From: Peder Bergan @ 2026-11-18 10:39 UTC (permalink / raw)
  To: Tamir Duberstein, Andreas Hindborg, Miguel Ojeda
  Cc: Boqun Feng, Gary Guo, Björn Roy Baron, Benno Lossin,
	Alice Ryhl, Trevor Gross, Danilo Krummrich, Daniel Almeida,
	Alexandre Courbot, Onur Özkan, rust-for-linux, linux-kernel,
	Jesung Yang

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.
---
 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>


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

end of thread, other threads:[~2026-11-18 10:45 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-18 10:39 [PATCH] rust: xarray: capture the iterator lifetime explicitly Peder Bergan
2026-11-18 10:39 ` Peder Bergan via B4 Relay
2026-11-18 10:45 ` Gary Guo

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.