diff options
| author | Gary Guo <gary@garyguo.net> | 2026-09-23 19:20:18 +0100 |
|---|---|---|
| committer | Gary Guo <gary@garyguo.net> | 2026-09-25 21:38:44 +0100 |
| commit | 666b3e7cfa3a5c6afbfb2b5dae017617dfc40863 (patch) | |
| tree | 0d0e112028772d7ca195334518a5402bcd7b0138 /tools/lib/python/kdoc/python_version.py | |
| parent | 6f78441c58c1012324da3189ea650cfeeb98966c (diff) | |
| download | linux-next-666b3e7cfa3a5c6afbfb2b5dae017617dfc40863.tar.gz linux-next-666b3e7cfa3a5c6afbfb2b5dae017617dfc40863.zip | |
rust: pin-init: add diagnostic attribute for `PinInit` and `Init`
Give a slightly more useful error message when these traits are not
implemented.
Before this change:
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
After this change:
error[E0277]: `impl pin_init::PinInit<Bar>` cannot be used to movably initialize `Bar` with error `_`
--> 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
|
= note: if your type implements `PinInit` but not `Init`, you might be forgetting a `#[pin]` annotation on fields
Ideally, we would generate differnet message when `PinInit` is implemented
but not `Init`; that is not feasible with today's
`diagnostics::on_unimplemented` attribute. However, the added note is worth
it because in `init!()` is more rarely used compared to `pin_init!()`; in
most cases `Init` being unimplemented is the result of missing `#[pin]`.
Link: https://patch.msgid.link/20260923-dev-pin-data-diag-v1-5-e4d7193569e5@garyguo.net
Signed-off-by: Gary Guo <gary@garyguo.net>
Diffstat (limited to 'tools/lib/python/kdoc/python_version.py')
0 files changed, 0 insertions, 0 deletions
