diff options
| author | Gary Guo <gary@garyguo.net> | 2026-09-23 15:06:13 +0100 |
|---|---|---|
| committer | Gary Guo <gary@garyguo.net> | 2026-09-28 12:42:52 +0100 |
| commit | 01c3d218e8fa5ac4393e7959701cd6c2e90c4a81 (patch) | |
| tree | 49b6e2b9a9b1f0750ee882395c50c2646265f789 /tools/lib/python | |
| parent | 666b3e7cfa3a5c6afbfb2b5dae017617dfc40863 (diff) | |
| download | linux-next-01c3d218e8fa5ac4393e7959701cd6c2e90c4a81.tar.gz linux-next-01c3d218e8fa5ac4393e7959701cd6c2e90c4a81.zip | |
rust: pin-init: internal: handle item and expr diagnostics differently
Currently `DiagCtxt` is used to allow error recovery in the pin-init
macros, by generating both a `compile_error!()` macro item and continue
expansion, and then merge token streams together. This works very well for
items, however for expressions, this will produce invalid expression and
result in a confusing error message.
error: macro expansion ignores `::` and any tokens following
--> tests/ui/compile-fail/zeroable/invalid_spread.rs:15:9
|
13 | let _ = init!(Foo {
| _____________-
14 | | a: 0,
15 | | ..MyZeroable::init_zeroed()
| | ^^^^^^^^^^^^^^^^^^^^^^^^^^^
16 | | });
| |______- caused by the macro expansion here
|
= note: the usage of `init!` is likely invalid in expression context
Fix this by wrap the concatenated diagnostics in a block, with the
generated expression in its tail position. This results in the desired
error message.
error: expected nothing or `..Zeroable::init_zeroed()`.
--> tests/ui/compile-fail/zeroable/invalid_spread.rs:15:9
|
15 | ..MyZeroable::init_zeroed()
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
Reviewed-by: Benno Lossin <lossin@kernel.org>
Link: https://patch.msgid.link/20260923140618.1978181-1-gary@kernel.org
Signed-off-by: Gary Guo <gary@garyguo.net>
Diffstat (limited to 'tools/lib/python')
0 files changed, 0 insertions, 0 deletions
