Open
Description
Code
struct A {
field1: String,
field2: String,
}
fn test(x: A) {
macro_rules! weird {
() => { let A { field1 } = x; }
}
weird!();
}
Current output
error: pattern requires `..` due to inaccessible fields
--> a.rs:8:21
|
8 | () => { let A { field1 } = x; }
| ^^^^^^^^^^^^
9 | }
10 | weird!();
| -------- in this macro invocation
|
= note: this error originates in the macro `weird` (in Nightly builds, run with -Z macro-backtrace for more info)
help: ignore the inaccessible and unused fields
|
8 | () => { let A { field1, .. } = x; }
| ++++
Desired output
error[E0027]: pattern does not mention field `field2`
--> a.rs:8:21
|
8 | () => { let A { field1 } = x; }
| ^^^^^^^^^^^^ missing field `field2`
|
Rationale and extra context
It seems this error message gets generated whenever an incomplete pattern shows up within a macro invocation, whether or not the fields are actually inaccessible.
Other cases
No response
Rust Version
rustc 1.83.0-nightly (f79a912 2024-09-18)
binary: rustc
commit-hash: f79a912
commit-date: 2024-09-18
host: x86_64-unknown-linux-gnu
release: 1.83.0-nightly
LLVM version: 19.1.0
Anything else?
No response