mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 0/3] rust: pin-init: provide better span for diagnostics
@ 2026-09-16 12:11 Gary Guo
  2026-09-16 12:11 ` [PATCH 1/3] rust: pin-init: internal: pin_init: emit `slot` using mixed site hygiene Gary Guo
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: Gary Guo @ 2026-09-16 12:11 UTC (permalink / raw)
  To: Benno Lossin, Gary Guo, Miguel Ojeda, Boqun Feng,
	Björn Roy Baron, Andreas Hindborg, Alice Ryhl, Trevor Gross,
	Danilo Krummrich, Daniel Almeida, Tamir Duberstein,
	Alexandre Courbot, Onur Özkan
  Cc: rust-for-linux, linux-kernel

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>


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2026-09-18 11:53 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-16 12:11 [PATCH 0/3] rust: pin-init: provide better span for diagnostics Gary Guo
2026-09-16 12:11 ` [PATCH 1/3] rust: pin-init: internal: pin_init: emit `slot` using mixed site hygiene Gary Guo
2026-09-16 12:11 ` [PATCH 2/3] rust: pin-init: internal: pin_init: use `slot` identifier directly with mixed site Gary Guo
2026-09-16 12:11 ` [PATCH 3/3] rust: pin-init: internal: pin_init: provide span for slot projection Gary Guo
2026-09-16 18:41 ` [PATCH 4/3] rust: pin-init: util: use span of `Index` for generated identifiers Gary Guo
2026-09-18 11:53 ` [PATCH 0/3] rust: pin-init: provide better span for diagnostics Gary Guo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®