Re: [PATCH 0/3] rust: pin-init: provide better span for diagnostics

From: Gary Guo

Date: Fri Sep 18 2026 - 08:27:20 EST


On Wed Sep 16, 2026 at 1:11 PM BST, Gary Guo wrote:
> 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 (4):
> rust: pin-init: internal: init: emit `slot` using mixed site hygiene
> rust: pin-init: internal: init: use `slot` identifier directly with mixed site
> rust: pin-init: internal: init: provide span for slot projection
> rust: pin-init: internal: use span of Index for generated identifiers

Applied to pin-init-next.

Best,
Gary