* [PATCH] rust: pin-init: use precise lifetime capture in list examples
@ 2026-11-18 10:40 Peder Bergan via B4 Relay
0 siblings, 0 replies; only message in thread
From: Peder Bergan via B4 Relay @ 2026-11-18 10:40 UTC (permalink / raw)
To: Benno Lossin, Gary Guo, Miguel Ojeda
Cc: Boqun Feng, Björn Roy Baron, Andreas Hindborg, Alice Ryhl,
Trevor Gross, Danilo Krummrich, Daniel Almeida, Tamir Duberstein,
Alexandre Courbot, Onur Özkan, rust-for-linux, linux-kernel,
Jesung Yang
From: Peder Bergan <peder.bergan@gmail.com>
The linked list insertion and mutex wait entry initializers borrow
the list they will link into. Express that dependency with precise
capturing bounds instead of using an outlives bound to capture the
list lifetime.
Precise capturing bounds are available at pin-init's minimum Rust
version of 1.82.
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 two examples passed on Rust 1.82 with std enabled and compiled
with std disabled. The standalone tests and doctests passed on
nightly.
OpenAI Codex assisted with the signature changes, testing and
drafting this commit message.
---
rust/pin-init/examples/linked_list.rs | 4 ++--
rust/pin-init/examples/mutex.rs | 2 +-
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/rust/pin-init/examples/linked_list.rs b/rust/pin-init/examples/linked_list.rs
index 424585fe226d..577106005cbd 100644
--- a/rust/pin-init/examples/linked_list.rs
+++ b/rust/pin-init/examples/linked_list.rs
@@ -39,7 +39,7 @@ pub fn new() -> impl PinInit<Self> {
#[inline]
#[allow(dead_code)]
- pub fn insert_next(list: &ListHead) -> impl PinInit<Self> + '_ {
+ pub fn insert_next(list: &ListHead) -> impl PinInit<Self> + use<'_> {
pin_init!(&this in Self {
prev: list.next.prev().replace(unsafe { Link::new_unchecked(this)}),
next: list.next.replace(unsafe { Link::new_unchecked(this)}),
@@ -48,7 +48,7 @@ pub fn insert_next(list: &ListHead) -> impl PinInit<Self> + '_ {
}
#[inline]
- pub fn insert_prev(list: &ListHead) -> impl PinInit<Self> + '_ {
+ pub fn insert_prev(list: &ListHead) -> impl PinInit<Self> + use<'_> {
pin_init!(&this in Self {
next: list.prev.next().replace(unsafe { Link::new_unchecked(this)}),
prev: list.prev.replace(unsafe { Link::new_unchecked(this)}),
diff --git a/rust/pin-init/examples/mutex.rs b/rust/pin-init/examples/mutex.rs
index e8d4dbb664fe..81b425cbfea9 100644
--- a/rust/pin-init/examples/mutex.rs
+++ b/rust/pin-init/examples/mutex.rs
@@ -163,7 +163,7 @@ struct WaitEntry {
impl WaitEntry {
#[inline]
- fn insert_new(list: &ListHead) -> impl PinInit<Self> + '_ {
+ fn insert_new(list: &ListHead) -> impl PinInit<Self> + use<'_> {
#[cfg(feature = "std")]
{
pin_init!(Self {
---
base-commit: aebb7274476403040d582c61478df8f4a7bf9cd3
change-id: 20261118-cleanup-pin-init-precise-capture-c03c4a56ab2f
Best regards,
--
Peder Bergan <peder.bergan@gmail.com>
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2026-11-18 10:40 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-18 10:40 [PATCH] rust: pin-init: use precise lifetime capture in list examples Peder Bergan via B4 Relay
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®