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

Gary Guo posted 3 patches 1 week, 1 day ago
rust/pin-init/internal/src/init.rs | 48 +++++++++++++++++---------------------
1 file changed, 21 insertions(+), 27 deletions(-)
[PATCH 0/3] rust: pin-init: provide better span for diagnostics
Posted by Gary Guo 1 week, 1 day ago
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@garyguo.net>
Re: [PATCH 0/3] rust: pin-init: provide better span for diagnostics
Posted by Gary Guo 6 days, 16 hours ago
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