Skip to content

Emit missing-fields diagnostics from inference#22336

Open
Twil3akine wants to merge 4 commits into
rust-lang:masterfrom
Twil3akine:missing-fields-inference
Open

Emit missing-fields diagnostics from inference#22336
Twil3akine wants to merge 4 commits into
rust-lang:masterfrom
Twil3akine:missing-fields-inference

Conversation

@Twil3akine
Copy link
Copy Markdown

@Twil3akine Twil3akine commented May 10, 2026

Implements one diagnostic FIXME from #22140.

This changes record-literal missing-fields diagnostics to be emitted from inference, while reusing the existing MissingFields diagnostic.

MissingFields already represents record literal/pattern missing field diagnostics and is rendered as rustc hard error E0063, so adding a separate diagnostic would duplicate behavior.

This PR:

  • reuses the existing MissingFields diagnostic
  • moves record-literal missing-fields emission from body validation into inference
  • keeps the existing record-pattern body validation path intact
  • does not add a new ide-assist or quick fix

Validated with:

cargo +nightly-2026-04-30 test -p ide-diagnostics missing_fields
cargo +nightly-2026-04-30 test -p ide-diagnostics
cargo +nightly-2026-04-30 test -p hir-ty
cargo +nightly-2026-04-30 test -p hir

AI assistance disclosure:
I used ChatGPT to help review the implementation plan and draft this PR description. I reviewed the generated suggestions before submitting.

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label May 10, 2026
Comment thread crates/hir-ty/src/infer/expr.rs Outdated
Comment thread crates/hir-ty/src/infer/expr.rs Outdated
remaining_fields.contains_key(&field.name).then_some(field_idx)
})
.collect::<Vec<_>>();
if !missing_fields.is_empty() {
Copy link
Copy Markdown
Contributor

@ChayimFriedman2 ChayimFriedman2 May 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This if is redundant, we already checked that above.

View changes since the review

Comment thread crates/hir/src/diagnostics.rs
Comment thread crates/hir/src/lib.rs
expr_store_diagnostics(db, acc, source_map);

let infer = InferenceResult::of(db, id);
let mut delayed_missing_fields_diagnostics = Vec::new();
Copy link
Copy Markdown
Contributor

@ChayimFriedman2 ChayimFriedman2 May 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do you delay this? I see no reason for that.

View changes since the review

Twil3akine and others added 2 commits May 10, 2026 17:55
Co-authored-by: Chayim Refael Friedman <chayimfr@gmail.com>
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented May 23, 2026

☔ The latest upstream changes (possibly #22252) made this pull request unmergeable. Please resolve the merge conflicts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-review Status: Awaiting review from the assignee but also interested parties.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants