Confusing note about "all struct fields are already assigned" when some fields are private
Open
@eggyal is already working on this.
Since Mar 2, 2026.
A-diagnostics
D-incorrect
T-compiler
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.1k
- PR merge metrics
- PR metrics pending
Description
Code
#![allow(unused)]
mod mem {
pub struct ProvenanceFrag<Provenance> {
provenance: Provenance,
position: usize,
}
}
use crate::mem::*;
fn mkthing<Provenance>(p: Provenance) {
let _f = ProvenanceFrag { provenance: p, pos: 0.into() };
}
Current output
error[E0560]: struct `mem::ProvenanceFrag<Provenance>` has no field named `pos`
--> src/lib.rs:13:46
|
13 | let _f = ProvenanceFrag { provenance: p, pos: 0.into() };
| ^^^ `mem::ProvenanceFrag<_>` does not have this field
|
= note: all struct fields are already assigned
Desired output
Rationale and extra context
Not entirely sure what the best output is here, but it definitely shouldn't say that all fields are already assigned when that is simply wrong.
Other cases
Rust Version
current nightly
Anything else?
No response
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.