History log of /linux/rust/pin-init/internal/src/util.rs (Results 1 – 9 of 9)
Revision Date Author Comments
# e2b2e013 02-May-2026 Gary Guo <gary@garyguo.net>

rust: pin-init: internal: pin_data: perform AST lifetime replacement if possible

Currently lifetimes are replaced via function type and `FnOutput` trait.
This is very general approach as it uses gen

rust: pin-init: internal: pin_data: perform AST lifetime replacement if possible

Currently lifetimes are replaced via function type and `FnOutput` trait.
This is very general approach as it uses generic associated type to replace
lifetime, so it can even work when macros are involved. This does cause
more generated code, and does not render in documentation nicely.

Thus, just replace the lifetime in the AST if no macros are involved.

Acked-by: Benno Lossin <lossin@kernel.org>
Link: https://patch.msgid.link/20261008-dev-selfref-v2-18-e280b3c8fba5@garyguo.net/
Signed-off-by: Gary Guo <gary@garyguo.net>

show more ...


# 5729b590 02-May-2026 Gary Guo <gary@garyguo.net>

rust: pin-init: internal: pin_data: check covariance of self-referential fields

We implicitly infer covariance for fields that self-references. This needs
to be checked to ensure that the fields are

rust: pin-init: internal: pin_data: check covariance of self-referential fields

We implicitly infer covariance for fields that self-references. This needs
to be checked to ensure that the fields are really covariant, so the rest
of expansion code can rely on this fact.

Acked-by: Benno Lossin <lossin@kernel.org>
Link: https://patch.msgid.link/20261008-dev-selfref-v2-7-e280b3c8fba5@garyguo.net/
Signed-off-by: Gary Guo <gary@garyguo.net>

show more ...


# 71293ee9 01-May-2026 Gary Guo <gary@garyguo.net>

rust: pin-init: internal: pin_data: self-referential drop order checks

Check drop order to ensure that usage of lifetime inside self-referential
struct is consistent with the order that the fields w

rust: pin-init: internal: pin_data: self-referential drop order checks

Check drop order to ensure that usage of lifetime inside self-referential
struct is consistent with the order that the fields will dropped in drop
glue.

First, fields are checked according to their index to ensure that if `a`
borrows from `b`, `b` must outlive `a`. This is simple and produces a very
good diagnostic when misused.

Lifetime bounds can also be indirectly crafted with implied bounds that
make fields well-formed. For example, in this struct

struct Foo {
x: &'b &'a (),
a: String,
y: PrintOnDrop<&'b str>,
b: String,
}

`&'b &'a ()` will imply that `a` outlive `b`, which is inconsistent with
the actual drop order. For this case, create a `__drop_order_check`
function with field lifetimes and outlive relationship of them as generic
parameter, and ask Rust to prove that the types are well-formed inside the
generated function, to ensure that the bad implied bounds cannot happen.

The `__drop_order_check` also need to correlate lifetimes or types captured
by generics and the field lifetimes. Do this by inserting outlive bounds
when a field mentions a specific type or lifetime parameter.

Acked-by: Benno Lossin <lossin@kernel.org>
Link: https://patch.msgid.link/20261008-dev-selfref-v2-6-e280b3c8fba5@garyguo.net/
Signed-off-by: Gary Guo <gary@garyguo.net>

show more ...


# 414b5c48 30-Apr-2026 Gary Guo <gary@garyguo.net>

rust: pin-init: internal: pin_data: infer self-referential struct

As a first step towards adding self-referential data structures in
pin-init, add parsing support.

Scan all field types for unbounde

rust: pin-init: internal: pin_data: infer self-referential struct

As a first step towards adding self-referential data structures in
pin-init, add parsing support.

Scan all field types for unbounded lifetimes, and if the names that of
fields, it is inferred as a self-referential field lifetime. No explicit
annotations are supported yet.

Acked-by: Benno Lossin <lossin@kernel.org>
Link: https://patch.msgid.link/20261008-dev-selfref-v2-2-e280b3c8fba5@garyguo.net/
Signed-off-by: Gary Guo <gary@garyguo.net>

show more ...


# 003a8953 06-Oct-2026 Gary Guo <gary@garyguo.net>

rust: pin-init: internal: add utility for extract a single attribute

More attributes are to be added which has the requirement that they should
only be specified once. Add a utility code to extract

rust: pin-init: internal: add utility for extract a single attribute

More attributes are to be added which has the requirement that they should
only be specified once. Add a utility code to extract attributes for a
specific path and report error when appeared multiple times.

Convert `#[pin]` parsing to use the added utility.

Acked-by: Benno Lossin <lossin@kernel.org>
Link: https://patch.msgid.link/20261006-dev-selfref-dep-v1-4-da716f740d6d@garyguo.net
Signed-off-by: Gary Guo <gary@garyguo.net>

show more ...


# 25e82b17 06-Oct-2026 Gary Guo <gary@garyguo.net>

rust: pin-init: internal: add utility to handle generics merging

There're many cases where we want to merge multiple generics together.
Currently this is done by cloning generics and modifying it, m

rust: pin-init: internal: add utility to handle generics merging

There're many cases where we want to merge multiple generics together.
Currently this is done by cloning generics and modifying it, making the
code less readable.

Add a utility code that allow printing multiple generics together, ensuring
correct ordering between lifetime and other parameters.

Acked-by: Benno Lossin <lossin@kernel.org>
Link: https://patch.msgid.link/20261006-dev-selfref-dep-v1-3-da716f740d6d@garyguo.net
Signed-off-by: Gary Guo <gary@garyguo.net>

show more ...


# dfb6a037 16-Sep-2026 Gary Guo <gary@garyguo.net>

rust: pin-init: internal: use span of `Index` for generated identifiers

Use the span of `Index` for generated identifiers, so diagnostics can point
to the span of the index.

Link: https://patch.msg

rust: pin-init: internal: use span of `Index` for generated identifiers

Use the span of `Index` for generated identifiers, so diagnostics can point
to the span of the index.

Link: https://patch.msgid.link/20260916184131.435059-1-gary@garyguo.net
Signed-off-by: Gary Guo <gary@garyguo.net>

show more ...


# 1ee699c4 04-Sep-2026 Mohamad Alsadhan <mo@sdhn.cc>

rust: pin-init: internal: pin_data: support tuple struct projections

`#[pin_data]` rejects tuple structs because it assumes every field has a
name, which it uses for the projection field, the `__Unp

rust: pin-init: internal: pin_data: support tuple struct projections

`#[pin_data]` rejects tuple structs because it assumes every field has a
name, which it uses for the projection field, the `__Unpin` field and the
pin-data accessor.

Identify fields by `syn::Member` instead, so that tuple fields are referred
to by their index in generated field accesses. The names that generated
items still need are derived from the index as `_0`, `_1`, etc.

The projection of a tuple struct is a tuple struct itself, so projected
fields are accessed with the same `.0`, `.1` syntax as on the input
type rather than through synthesised names.

Signed-off-by: Mohamad Alsadhan <mo@sdhn.cc>
[ Moved utility code to util.rs as extension trait - Gary ]
Link: https://patch.msgid.link/20260904-tuple-struct-v1-2-72c50bd037fd@garyguo.net
Signed-off-by: Gary Guo <gary@garyguo.net>

show more ...


# c2bc9bd6 04-Sep-2026 Gary Guo <gary@garyguo.net>

rust: pin-init: internal: extract utility code to new module

Create a new `util.rs` to host utility code that are generic and can be
shared by multiple macros.

Link: https://patch.msgid.link/202609

rust: pin-init: internal: extract utility code to new module

Create a new `util.rs` to host utility code that are generic and can be
shared by multiple macros.

Link: https://patch.msgid.link/20260904-tuple-struct-v1-1-72c50bd037fd@garyguo.net
Signed-off-by: Gary Guo <gary@garyguo.net>

show more ...