From: "Gary Guo" <gary@garyguo.net>
To: "Gary Guo" <gary@garyguo.net>, "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>
Subject: Re: [PATCH 0/5] rust: pin-init: improve diagnostics of missing `#[pin_data]` and `#[pin]`
Date: Fri, 25 Sep 2026 21:41:54 +0100 [thread overview]
Message-ID: <DLOOT8LDHDKA.3853XGXDK1GFI@garyguo.net> (raw)
In-Reply-To: <20260923-dev-pin-data-diag-v1-0-e4d7193569e5@garyguo.net>
On Wed Sep 23, 2026 at 7:20 PM BST, Gary Guo wrote:
> Improve the diagnostics of missing `#[pin_data]` and `#[pin]`, by adding
> diagnostics attributes. For `#[pin_data]`, we have to change the expansion
> to retrieve `PinData` in a two-step process, so we change the error message
> from "method exists but trait bound not satisfied" to "trait not
> implemented".
>
> This is the new error message for missing `#[pin_data]`:
>
> error[E0277]: `Foo` cannot be used with `pin_init!` macro
> --> tests/ui/compile-fail/init/missing_pin_data.rs:9:19
> |
> 9 | pin_init!(Self { a: 42 })
> | ^^^^ unsatisfied trait bound
> |
> help: the trait `pin_init::__internal::HasPinData` is not implemented for `Foo`
>
> where it was previously
>
> error[E0599]: no associated function or constant named `__pin_data` found for struct `Foo` in the current scope
> --> tests/ui/compile-fail/init/missing_pin_data.rs:9:9
> |
> 3 | struct Foo {
> | ---------- associated function or constant `__pin_data` not found for this struct
> ...
> 9 | pin_init!(Self { a: 42 })
> | ^^^^^^^^^^^^^^^^^^^^^^^^^ associated function or constant not found in `Foo`
> |
> = 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: `pin_init::__internal::HasPinData`
>
> and this is the new error message for missing `#[pin]`:
>
> error[E0277]: `impl PinInit<usize>` cannot be used to movably initialize `usize` with error `_`
> --> tests/ui/compile-fail/pin_data/missing_pin.rs:12:18
> |
> 12 | a <- a,
> | -----^
> | | |
> | | the trait `Init<usize, _>` is not implemented for `impl PinInit<usize>`
> | required by a bound introduced by this call
> |
> = note: if your type implements `PinInit` but not `Init`, you might be forgetting a `#[pin]` annotation on fields
>
> where it was previously
>
> error[E0277]: the trait bound `impl pin_init::PinInit<Bar>: Init<Bar, _>` is not satisfied
> --> tests/ui/compile-fail/init/invalid_init.rs:19:16
> |
> 19 | bar <- Bar::new(),
> | -------^^^^^^^^^^
> | | |
> | | the trait `Init<Bar, _>` is not implemented for `impl pin_init::PinInit<Bar>`
> | required by a bound introduced by this call
>
> Signed-off-by: Gary Guo <gary@garyguo.net>
> ---
> Gary Guo (5):
> rust: pin-init: internal: make `__init_data` and `__pin_data` safe
> rust: pin-init: internal: remove associated type of `HasInitData`
> rust: pin-init: internal: use `HasInitData` to provide inference help only
> rust: pin-init: internal: add custom diagnostic when `#[pin_data]` is not implemented
> rust: pin-init: add diagnostic attribute for `PinInit` and `Init`
Applied to pin-init-next, with typo pointed out by Sashiko fixed.
Best,
Gary
>
> rust/pin-init/internal/src/init.rs | 25 +++++++++---------
> rust/pin-init/internal/src/pin_data.rs | 2 +-
> rust/pin-init/src/__internal.rs | 48 +++++++++++++++-------------------
> rust/pin-init/src/lib.rs | 11 +++++++-
> 4 files changed, 45 insertions(+), 41 deletions(-)
> ---
> base-commit: dfb6a037fd586f1ffcba3b143dab58f5c88294d1
> change-id: 20260923-dev-pin-data-diag-65209ab751fc
>
> Best regards,
> --
> Gary Guo <gary@garyguo.net>
prev parent reply other threads:[~2026-09-25 20:41 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-23 18:20 Gary Guo
2026-09-23 18:20 ` [PATCH 1/5] rust: pin-init: internal: make `__init_data` and `__pin_data` safe Gary Guo
2026-09-23 18:20 ` [PATCH 2/5] rust: pin-init: internal: remove associated type of `HasInitData` Gary Guo
2026-09-23 18:20 ` [PATCH 3/5] rust: pin-init: internal: use `HasInitData` to provide inference help only Gary Guo
2026-09-23 18:20 ` [PATCH 4/5] rust: pin-init: internal: add custom diagnostic when `#[pin_data]` is not implemented Gary Guo
2026-09-23 18:20 ` [PATCH 5/5] rust: pin-init: add diagnostic attribute for `PinInit` and `Init` Gary Guo
2026-09-25 20:41 ` Gary Guo [this message]
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=DLOOT8LDHDKA.3853XGXDK1GFI@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®