Skip to contentSkip to conversation

Rust pin-init for v7.0

GIT PULL Applied Benno Lossin 2 participants 3 messages Jan 22 – Jan 28 Rust

lore
Share & tools
lore

Benno Lossin

author reviewer
#0 lore raw

Hi Miguel,

Lot's of changes in this one, mainly the syn rewrite, but also some smaller changes such as removing the try_ versions of the macros in pin-init (the kernel still declares its own).

All commits have been in linux-next since Monday.

The first commit in my tree is also in the syn patch series from Gary [1], to avoid problems it should be merged after this tag. There also is a "phantom conflict" with 74e15ac34b098 ("scripts:
generate_rust_analyzer: Add pin_init_internal deps") in rust-fixes, which you already saw in linux-next [2]. Otherwise no conflicts expected.

Please pull for v7.0 -- thanks!

Cheers,
Benno

[1]: https://lore.kernel.org/all/[email protected]
[2]: https://lore.kernel.org/all/[email protected]

The following changes since commit 0f61b1860cc3f52aef9036d7235ed1f017632193:

Linux 6.19-rc5 (2026-01-11 17:03:14 -1000)

are available in the Git repository at:

https://github.com/Rust-for-Linux/linux.git tags/pin-init-v7.0

for you to fetch changes up to aeb5ecad5316f6af160993915163367290825b6b:

rust: pin-init: Implement InPlaceWrite<T> for &'static mut MaybeUninit<T> (2026-01-17 10:53:28 +0100)

----------------------------------------------------------------
pin-init changes for v7.0

Added:

- '&'static mut MaybeUninit<T>' now implements 'InPlaceWrite'. This enables users to use external allocation mechanisms such as 'static_cell'.

- Gary Guo as a Maintainer.

Changed:

- Rewrote all proc-macros ('[pin_]init!', '#[pin_data]', '#[pinned_drop]', 'derive([Maybe]Zeroable)'), using 'syn' with better diagnostics.

- 'derive([Maybe]Zeroable)' now support tuple structs.

- '[pin_]init!' now supports attributes on fields (such as '#[cfg(...)]').

- Add a '#[default_error(<type>)]' attribute to '[pin_]init!' to override the default error (when no '? Error' is specified).

- Support packed struct in '[pin_]init!' with
'#[disable_initialized_field_access]'.

Removed:

- 'try_[pin_]init!' have been removed in favor of merging their feature with '[pin_]init!'. The kernel's own 'try_[pin_]init!' macros have been updated to use the 'default_error' attribute.

Fixed:

- Corrected 'T: Sized' bounds to 'T: ?Sized' in the generated 'PinnedDrop' check by '#[pin_data]'.

----------------------------------------------------------------
Benno Lossin (15):
rust: pin-init: remove try_ versions of the initializer macros
rust: pin-init: allow the crate to refer to itself as pin-init in doc tests
rust: pin-init: add syn dependency and remove proc-macro[2] and quote workarounds
rust: pin-init: internal: add utility API for syn error handling
rust: pin-init: rewrite derive(Zeroable) and derive(MaybeZeroable) using syn
rust: pin-init: rewrite the #[pinned_drop] attribute macro using syn
rust: pin-init: rewrite #[pin_data] using syn
rust: pin-init: add ?Sized bounds to traits in #[pin_data] macro
rust: pin-init: rewrite the initializer macros using syn
rust: pin-init: add #[default_error(<type>)] attribute to initializer macros
rust: init: use #[default_error(err)] for the initializer macros
rust: pin-init: internal: init: add support for attributes on initializer fields
rust: pin-init: internal: init: add escape hatch for referencing initialized fields
rust: pin-init: internal: init: simplify Zeroable safety check
MAINTAINERS: add Gary Guo to pin-init

Oleksandr Babak (1):
rust: pin-init: Implement InPlaceWrite<T> for &'static mut MaybeUninit<T>

 MAINTAINERS                               |    1 +
 rust/Makefile                             |   16 +-
 rust/kernel/init.rs                       |   40 +-
 rust/pin-init/README.md                   |    2 +-
 rust/pin-init/examples/linked_list.rs     |   19 +-
 rust/pin-init/examples/pthread_mutex.rs   |   10 +-
 rust/pin-init/internal/src/diagnostics.rs |   30 +
 rust/pin-init/internal/src/helpers.rs     |  152 ---
 rust/pin-init/internal/src/init.rs        |  548 ++++++++++
 rust/pin-init/internal/src/lib.rs         |   48 +-
 rust/pin-init/internal/src/pin_data.rs    |  615 +++++++++--
 rust/pin-init/internal/src/pinned_drop.rs |   88 +-
 rust/pin-init/internal/src/zeroable.rs    |  157 ++-
 rust/pin-init/src/lib.rs                  |  200 +---
 rust/pin-init/src/macros.rs               | 1677 -----------------------------
 scripts/generate_rust_analyzer.py         |    2 +-
 16 files changed, 1305 insertions(+), 2300 deletions(-)
 create mode 100644 rust/pin-init/internal/src/diagnostics.rs
 delete mode 100644 rust/pin-init/internal/src/helpers.rs
 create mode 100644 rust/pin-init/internal/src/init.rs
 delete mode 100644 rust/pin-init/src/macros.rs
Applied
#1 lore raw
Quoted 9 lines · Benno Lossin

Hi Miguel,

Lot's of changes in this one, mainly the syn rewrite, but also some smaller changes such as removing the try_ versions of the macros in pin-init (the kernel still declares its own).

All commits have been in linux-next since Monday.

Quoted 8 lines

The first commit in my tree is also in the syn patch series from Gary [1], to avoid problems it should be merged after this tag. There also is a "phantom conflict" with 74e15ac34b098 ("scripts:
generate_rust_analyzer: Add pin_init_internal deps") in rust-fixes, which you already saw in linux-next [2]. Otherwise no conflicts expected.

Please pull for v7.0 -- thanks!

Merged into rust-next and Gary's series (without his first patch) right after that -- thank you!

By the way, in the PR message, it would be nice if you could use the imperative, since that is nowadays the style maintainers should use for PRs. I reworded it a bit to conform, please take a look.

e.g. instead of "'...' now support ...", I wrote "Support ... in '...'" (and so on).

Cheers,
Miguel

author reviewer
#2 lore raw
Quoted 17 lines · Miguel Ojeda
Quoted 16 lines · Benno Lossin

Hi Miguel,

Lot's of changes in this one, mainly the syn rewrite, but also some smaller changes such as removing the try_ versions of the macros in pin-init (the kernel still declares its own).

All commits have been in linux-next since Monday.

The first commit in my tree is also in the syn patch series from Gary [1], to avoid problems it should be merged after this tag. There also is a "phantom conflict" with 74e15ac34b098 ("scripts:
generate_rust_analyzer: Add pin_init_internal deps") in rust-fixes, which you already saw in linux-next [2]. Otherwise no conflicts expected.

Quoted 8 lines
Quoted 1 line

Please pull for v7.0 -- thanks!

Merged into rust-next and Gary's series (without his first patch) right after that -- thank you!

By the way, in the PR message, it would be nice if you could use the imperative, since that is nowadays the style maintainers should use for PRs.

Will do!

Quoted 1 line

I reworded it a bit to conform, please take a look.

Changes look good to me.

Cheers,
Benno