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.
Thanks for your report, good catch! I'm pretty sure my closed PR #116575 would address it, though I have to double-check. Will try to rework the PR soon and reopen.
Code
Current output
Desired output
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 (f79a912d9 2024-09-18) binary: rustc commit-hash: f79a912d9edc3ad4db910c0e93672ed5c65133fa 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