From: Gary Guo <gary@garyguo.net>
To: "Benno Lossin" <lossin@kernel.org>,
"Miguel Ojeda" <ojeda@kernel.org>,
"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>
Cc: rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org,
Gary Guo <gary@garyguo.net>
Subject: [PATCH 7/8] rust: pin-init: internal: pin_data: rename `'__pin` lifetime to `'__this`
Date: Tue, 06 Oct 2026 17:29:37 +0200 [thread overview]
Message-ID: <20261006-dev-selfref-dep-v1-7-da716f740d6d@garyguo.net> (raw)
In-Reply-To: <20261006-dev-selfref-dep-v1-0-da716f740d6d@garyguo.net>
"pin" is a very overloaded word in pin-init. For the generated projection
structs, the lifetime refer to that of the whole struct, so rename the
lifetime used in expansion from `'__pin` to `'__this` instead.
The `__pin_phantom_data` field is renamed to `__this` for the same reason
and for clarity purpose, capture a `PhantomData` of the mutable reference
to the struct.
Signed-off-by: Gary Guo <gary@garyguo.net>
---
rust/pin-init/internal/src/pin_data.rs | 26 +++++++++++++-------------
1 file changed, 13 insertions(+), 13 deletions(-)
diff --git a/rust/pin-init/internal/src/pin_data.rs b/rust/pin-init/internal/src/pin_data.rs
index a4d6965c1572..6e18bc9e890a 100644
--- a/rust/pin-init/internal/src/pin_data.rs
+++ b/rust/pin-init/internal/src/pin_data.rs
@@ -325,11 +325,11 @@ fn generate_projections(
is_tuple_struct: bool,
fields: &[FieldInfo<'_>],
) -> TokenStream {
- let pin_lt_generics: Generics = parse_quote!(<'__pin>);
- let generics_with_pin_lt = CombinedGenerics(vec![&pin_lt_generics, generics]);
+ let this_lt_generics: Generics = parse_quote!(<'__this>);
+ let generics_with_this_lt = CombinedGenerics(vec![&this_lt_generics, generics]);
let (impl_generics, ty_generics, whr) = generics.split_for_impl();
- let (_, ty_generics_with_pin_lt, _) = generics_with_pin_lt.split_for_impl();
+ let (_, ty_generics_with_this_lt, _) = generics_with_this_lt.split_for_impl();
let this = format_ident!("this");
@@ -348,7 +348,7 @@ fn generate_projections(
if field.pinned {
(
quote!(
- #vis #name ::core::pin::Pin<&'__pin mut #ty>,
+ #vis #name ::core::pin::Pin<&'__this mut #ty>,
),
quote!(
// SAFETY: this field is structurally pinned.
@@ -358,7 +358,7 @@ fn generate_projections(
} else {
(
quote!(
- #vis #name &'__pin mut #ty,
+ #vis #name &'__this mut #ty,
),
quote!(
#name &mut #this.#member,
@@ -379,9 +379,9 @@ fn generate_projections(
let (projection_def, projection_init) = if is_tuple_struct {
(
quote! {
- #vis struct __Projection #generics_with_pin_lt (
+ #vis struct __Projection #generics_with_this_lt (
#(#fields_decl)*
- ::core::marker::PhantomData<&'__pin mut ()>,
+ ::core::marker::PhantomData<&'__this mut #ident #ty_generics>,
) #whr;
},
quote! {
@@ -394,17 +394,17 @@ fn generate_projections(
} else {
(
quote! {
- #vis struct __Projection #generics_with_pin_lt
+ #vis struct __Projection #generics_with_this_lt
#whr
{
#(#fields_decl)*
- ___pin_phantom_data: ::core::marker::PhantomData<&'__pin mut ()>,
+ __this: ::core::marker::PhantomData<&'__this mut #ident #ty_generics>,
}
},
quote! {
__Projection {
#(#fields_proj)*
- ___pin_phantom_data: ::core::marker::PhantomData,
+ __this: ::core::marker::PhantomData,
}
},
)
@@ -428,9 +428,9 @@ impl #impl_generics #ident #ty_generics
/// These fields are **not** structurally pinned:
#(#[doc = #not_structurally_pinned_fields_docs])*
#[inline]
- #vis fn project<'__pin>(
- self: ::core::pin::Pin<&'__pin mut Self>,
- ) -> __Projection #ty_generics_with_pin_lt {
+ #vis fn project<'__this>(
+ self: ::core::pin::Pin<&'__this mut Self>,
+ ) -> __Projection #ty_generics_with_this_lt {
// SAFETY: we only give access to `&mut` for fields not structurally pinned.
let #this = unsafe { ::core::pin::Pin::get_unchecked_mut(self) };
#projection_init
--
2.54.0
next prev parent reply other threads:[~2026-10-06 15:30 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-06 15:29 [PATCH 0/8] rust: pin-init: various cleanups to prepare for self-reference Gary Guo
2026-10-06 15:29 ` [PATCH 1/8] rust: pin-init: internal: init: forget guards in reverse order Gary Guo
2026-10-06 15:29 ` [PATCH 2/8] rust: pin-init: internal: init: set span location of guards Gary Guo
2026-10-06 15:29 ` [PATCH 3/8] rust: pin-init: internal: add utility to handle generics merging Gary Guo
2026-10-06 15:29 ` [PATCH 4/8] rust: pin-init: internal: add utility for extract a single attribute Gary Guo
2026-10-06 15:29 ` [PATCH 5/8] rust: pin-init: internal: pin_data: move projection struct into `const _: ()` block Gary Guo
2026-10-06 15:29 ` [PATCH 6/8] rust: pin-init: internal: pin_data: extract `#[cfg]` processing to its own function Gary Guo
2026-10-06 15:29 ` Gary Guo [this message]
2026-10-06 15:29 ` [PATCH 8/8] rust: pin-init: internal: pin_data: parse into `StructInfo` before generating Gary Guo
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=20261006-dev-selfref-dep-v1-7-da716f740d6d@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=rust-for-linux@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 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®