From: Peder Bergan via B4 Relay <devnull+peder.bergan.gmail.com@kernel.org>
To: Benno Lossin <lossin@kernel.org>, Gary Guo <gary@garyguo.net>,
Miguel Ojeda <ojeda@kernel.org>
Cc: "Boqun Feng" <boqun@kernel.org>,
"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>,
"Daniel Almeida" <daniel.almeida@collabora.com>,
"Tamir Duberstein" <tamird@kernel.org>,
"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: [PATCH] rust: pin-init: use precise lifetime capture in list examples
Date: Wed, 18 Nov 2026 11:40:00 +0100 [thread overview]
Message-ID: <20261118-cleanup-pin-init-precise-capture-v1-1-60f6e06d66f6@gmail.com> (raw)
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>
reply other threads:[~2026-11-18 10:40 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20261118-cleanup-pin-init-precise-capture-v1-1-60f6e06d66f6@gmail.com \
--to=devnull+peder.bergan.gmail.com@kernel.org \
--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=gary@garyguo.net \
--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®