From d4a14259b881a388be13e0f1e30f715637b7e21b Mon Sep 17 00:00:00 2001 From: Benno Lossin Date: Thu, 22 Jan 2026 10:39:08 +0100 Subject: [PATCH 1/2] tests: update nightly output Signed-off-by: Benno Lossin --- .../compile-fail/init/missing_pin_data.stderr | 2 +- .../pin_data/no_pin_on_phantompinned.stderr | 23 ------------------- tests/ui/compile-fail/pin_data/twice.stderr | 2 +- .../ui/compile-fail/pinned_drop/no_fn.stderr | 2 +- .../no_pin_data_but_pinned_drop.stderr | 4 ++-- .../pinned_drop/unexpected_item.stderr | 2 +- .../pinned_drop/wrong_receiver.stderr | 4 ++-- 7 files changed, 8 insertions(+), 31 deletions(-) diff --git a/tests/ui/compile-fail/init/missing_pin_data.stderr b/tests/ui/compile-fail/init/missing_pin_data.stderr index 1215692b..fa497c6a 100644 --- a/tests/ui/compile-fail/init/missing_pin_data.stderr +++ b/tests/ui/compile-fail/init/missing_pin_data.stderr @@ -9,5 +9,5 @@ error[E0599]: no associated item named `__pin_data` found for struct `Foo` in th | = help: items from traits can only be used if the trait is implemented and in scope = note: the following trait defines an item `__pin_data`, perhaps you need to implement it: - candidate #1: `HasPinData` + candidate #1: `pin_init::__internal::HasPinData` = note: this error originates in the macro `pin_init` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/tests/ui/compile-fail/pin_data/no_pin_on_phantompinned.stderr b/tests/ui/compile-fail/pin_data/no_pin_on_phantompinned.stderr index 63d59d69..fedd62ab 100644 --- a/tests/ui/compile-fail/pin_data/no_pin_on_phantompinned.stderr +++ b/tests/ui/compile-fail/pin_data/no_pin_on_phantompinned.stderr @@ -21,26 +21,3 @@ error: The field `pin4` of type `PhantomPinned` only has an effect if it has the | 9 | pin4: ::core::marker::PhantomPinned, | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error[E0425]: cannot find type `PhantomPinned` in this scope - --> tests/ui/compile-fail/pin_data/no_pin_on_phantompinned.rs:6:11 - | -6 | pin1: PhantomPinned, - | ^^^^^^^^^^^^^ not found in this scope - | -help: consider importing this struct - | -1 + use std::marker::PhantomPinned; - | - -error[E0433]: failed to resolve: use of unresolved module or unlinked crate `marker` - --> tests/ui/compile-fail/pin_data/no_pin_on_phantompinned.rs:7:11 - | -7 | pin2: marker::PhantomPinned, - | ^^^^^^ use of unresolved module or unlinked crate `marker` - | - = help: if you wanted to use a crate named `marker`, use `cargo add marker` to add it to your `Cargo.toml` -help: consider importing this module - | -1 + use std::marker; - | diff --git a/tests/ui/compile-fail/pin_data/twice.stderr b/tests/ui/compile-fail/pin_data/twice.stderr index 274912e3..abae43e5 100644 --- a/tests/ui/compile-fail/pin_data/twice.stderr +++ b/tests/ui/compile-fail/pin_data/twice.stderr @@ -9,7 +9,7 @@ error[E0428]: the name `FooProjection` is defined multiple times = note: `FooProjection` must be defined only once in the type namespace of this module = note: this error originates in the attribute macro `pin_data` (in Nightly builds, run with -Z macro-backtrace for more info) -error[E0119]: conflicting implementations of trait `HasPinData` for type `Foo` +error[E0119]: conflicting implementations of trait `pin_init::__internal::HasPinData` for type `Foo` --> tests/ui/compile-fail/pin_data/twice.rs:4:1 | 3 | #[pin_data] diff --git a/tests/ui/compile-fail/pinned_drop/no_fn.stderr b/tests/ui/compile-fail/pinned_drop/no_fn.stderr index f82b3006..50241e4a 100644 --- a/tests/ui/compile-fail/pinned_drop/no_fn.stderr +++ b/tests/ui/compile-fail/pinned_drop/no_fn.stderr @@ -4,4 +4,4 @@ error[E0046]: not all trait items implemented, missing: `drop` 7 | impl PinnedDrop for Foo {} | ^^^^^^^^^^^^^^^^^^^^^^^ missing `drop` in implementation | - = help: implement the missing item: `fn drop(self: Pin<&mut Self>, _: OnlyCallFromDrop) { todo!() }` + = help: implement the missing item: `fn drop(self: Pin<&mut Self>, _: pin_init::__internal::OnlyCallFromDrop) { todo!() }` diff --git a/tests/ui/compile-fail/pinned_drop/no_pin_data_but_pinned_drop.stderr b/tests/ui/compile-fail/pinned_drop/no_pin_data_but_pinned_drop.stderr index 54cb8f68..80f94c62 100644 --- a/tests/ui/compile-fail/pinned_drop/no_pin_data_but_pinned_drop.stderr +++ b/tests/ui/compile-fail/pinned_drop/no_pin_data_but_pinned_drop.stderr @@ -1,10 +1,10 @@ -error[E0277]: the trait bound `Foo: HasPinData` is not satisfied +error[E0277]: the trait bound `Foo: pin_init::__internal::HasPinData` is not satisfied --> tests/ui/compile-fail/pinned_drop/no_pin_data_but_pinned_drop.rs:7:21 | 7 | impl PinnedDrop for Foo { | ^^^ unsatisfied trait bound | -help: the trait `HasPinData` is not implemented for `Foo` +help: the trait `pin_init::__internal::HasPinData` is not implemented for `Foo` --> tests/ui/compile-fail/pinned_drop/no_pin_data_but_pinned_drop.rs:4:1 | 4 | struct Foo {} diff --git a/tests/ui/compile-fail/pinned_drop/unexpected_item.stderr b/tests/ui/compile-fail/pinned_drop/unexpected_item.stderr index 6f564a2b..1607d088 100644 --- a/tests/ui/compile-fail/pinned_drop/unexpected_item.stderr +++ b/tests/ui/compile-fail/pinned_drop/unexpected_item.stderr @@ -10,4 +10,4 @@ error[E0046]: not all trait items implemented, missing: `drop` 7 | impl PinnedDrop for Foo { | ^^^^^^^^^^^^^^^^^^^^^^^ missing `drop` in implementation | - = help: implement the missing item: `fn drop(self: Pin<&mut Self>, _: OnlyCallFromDrop) { todo!() }` + = help: implement the missing item: `fn drop(self: Pin<&mut Self>, _: pin_init::__internal::OnlyCallFromDrop) { todo!() }` diff --git a/tests/ui/compile-fail/pinned_drop/wrong_receiver.stderr b/tests/ui/compile-fail/pinned_drop/wrong_receiver.stderr index 678672af..b4896625 100644 --- a/tests/ui/compile-fail/pinned_drop/wrong_receiver.stderr +++ b/tests/ui/compile-fail/pinned_drop/wrong_receiver.stderr @@ -4,8 +4,8 @@ error[E0053]: method `drop` has an incompatible type for trait 8 | fn drop(&mut self) {} | ^^^^^^^^^ expected `Pin<&mut Foo>`, found `&mut Foo` | - = note: expected signature `fn(Pin<&mut Foo>, OnlyCallFromDrop)` - found signature `fn(&mut Foo, OnlyCallFromDrop)` + = note: expected signature `fn(Pin<&mut Foo>, pin_init::__internal::OnlyCallFromDrop)` + found signature `fn(&mut Foo, pin_init::__internal::OnlyCallFromDrop)` help: change the self-receiver type to match the trait | 8 - fn drop(&mut self) {} From eb3a261f9624773a4811e14780a1235a756185da Mon Sep 17 00:00:00 2001 From: Benno Lossin Date: Thu, 22 Jan 2026 10:49:18 +0100 Subject: [PATCH 2/2] fix changelog There were a couple of things missed/wrong in the previous PRs. Signed-off-by: Benno Lossin --- CHANGELOG.md | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3d6bbdf1..56b248b3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,7 +12,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - `[pin_]init_scope` functions to run arbitrary code inside of an initializer. - `&'static mut MaybeUninit` now implements `InPlaceWrite`. This enables users to use external allocation mechanisms such as `static_cell`. -- Rewrote all proc-macros using `syn`. ### Changed @@ -22,7 +21,23 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 code at that point. - Make the `[try_][pin_]init!` macros expose initialized fields via a `let` binding as `&mut T` or `Pin<&mut T>` for later fields. -- `derive([Maybe]Zeroable)` now support tuple structs +- 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()]` 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!`. + +### Fixed + +- Corrected `T: Sized` bounds to `T: ?Sized` in the generated `PinnedDrop` + check by `#[pin_data]`. ## [0.0.10] - 2025-08-19