rust-lang / rust-lang/rust

Confusing note about "all struct fields are already assigned" when some fields are private

Open
#153,259 3 comments 0 reactions 1 assignee View on GitHub

@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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.