Code
use crate::m::S;
mod m {
pub(crate) struct S {
pub(crate) visible: u64,
not_visible: u64,
}
impl S {
pub(crate) fn new() -> Self {
loop {}
}
}
}
pub fn main() {
let S {
visible,
} = S::new();
}
Current output
error: pattern requires `..` due to inaccessible fields
--> <source>:17:9
|
17 | let S {
| _________^
18 | | visible,
19 | | } = S::new();
| |_____^
|
help: ignore the inaccessible and unused fields
|
18 | visible, ..,
| ++++
error: aborting due to 1 previous error
Compiler returned: 1
Desired output
error: pattern requires `..` due to inaccessible fields
--> <source>:17:9
|
17 | let S {
| _________^
18 | | visible,
19 | | } = S::new();
| |_____^
|
help: ignore the inaccessible and unused fields
|
18 | visible, ..
| +++
error: aborting due to 1 previous error
Compiler returned: 1
Rationale and extra context
.. does not allow trailing commas, so the suggestion should not contain one.
Other cases
Rust Version
$ rustc --version --verbose
rustc 1.94.0-nightly (ba2142a19 2025-12-07)
binary: rustc
commit-hash: ba2142a19c1acabe770433418fa395b8a0ef47a4
commit-date: 2025-12-07
host: x86_64-unknown-linux-gnu
release: 1.94.0-nightly
LLVM version: 21.1.5
Anything else?
Godbolt link: https://godbolt.org/z/TajKnGfe5
Code
Current output
Desired output
Rationale and extra context
..does not allow trailing commas, so the suggestion should not contain one.Other cases
Rust Version
Anything else?
Godbolt link: https://godbolt.org/z/TajKnGfe5