[PATCH 0/3] rust: pin-init: provide better span for diagnostics
From: Gary Guo
Date: Wed Sep 16 2026 - 08:24:47 EST
When initializing a field, pin-init first projects the full slot to a slot
of the field, then initialize it by invoking a method. Currently the span
location is not explicitly set, so the error message points to the full
macro invocation.
Improve it by provide a span, so Rust will point to the specific fields
causing the error when type check fails.
Old error message:
error[E0308]: mismatched types
--> tests/ui/compile-fail/init/field_value_wrong_type.rs:8:28
|
8 | let _ = init!(Foo { a: () });
| ---------------^^---
| | |
| | expected `usize`, found `()`
| arguments to this method are incorrect
New error message:
error[E0308]: mismatched types
--> tests/ui/compile-fail/init/field_value_wrong_type.rs:8:28
|
8 | let _ = init!(Foo { a: () });
| ---^^
| | |
| | expected `usize`, found `()`
| arguments to this method are incorrect
---
Gary Guo (3):
rust: pin-init: internal: pin_init: emit `slot` using mixed site hygiene
rust: pin-init: internal: pin_init: use `slot` identifier directly with mixed site
rust: pin-init: internal: pin_init: provide span for slot projection
rust/pin-init/internal/src/init.rs | 48 +++++++++++++++++---------------------
1 file changed, 21 insertions(+), 27 deletions(-)
---
base-commit: 3b3ff9034a497fb3b8429f6fe8ba5697bc7dcebd
change-id: 20260916-dev-hygiene-5473c74b5b63
Best regards,
--
Gary Guo <gary@xxxxxxxxxxx>