Skip to content

rust: pin-init: provide better span for diagnostics

Gary Guo lkml rust-for-linux 1 version Applied

Status from this message: Applied to pin-init-next.

Get series with b4
b4 am [email protected] change-id 20260916-dev-hygiene-5473c74b5b63

Versions newest first

  1. v1 Latest3 patches 2 repliesApplied

Patches in v1 Applied

#Subject and filesSizeRepliesApplied
1/3rust: pin-init: internal: pin_init: emit `slot` using mixed site hygienerust/pin-init/internal/src/init.rs+5 -50 replies
2/3rust: pin-init: internal: pin_init: use `slot` identifier directly with mixed siterust/pin-init/internal/src/init.rs+12 -190 replies
3/3rust: pin-init: internal: pin_init: provide span for slot projectionrust/pin-init/internal/src/init.rs+7 -60 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

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

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,

Signature · 1 line
Gary Guo <[email protected]>