Skip filled in fields when suggesting field names #111149
Labels
A-diagnostics
Area: Messages for errors, warnings, and lints
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
Code
Current output
Desired output
https://play.rust-lang.org/?version=nightly&mode=debug&edition=2021&gist=b2d383789fe03fc2ca056487e3e7eb10
Rationale and extra context
We can't set a field on a struct more than once, so we can discount those already (likely correctly) set fields from the set of available fields to choose from. This is especially useful if you're only following the compiler error messages as the current error output does not mention
giraffe
in the error message. If I'm coding blind I get prompted correctly what the first few fields of the struct are named, but once I've filled in the first 5 fields correctly there's no more hints on the other fields. If we exclude the fields we've already filled in then rustc should be able to hint me to get to the end of a struct no matter how many fields it has (after a few compiles as I fill in what I need to).Other cases
This would be especially useful if I am filling out a struct that has been autogenerated by some macro and I can't easily view the source of it.
Anything else?
This just seems like a cute quality of life improvement in the diagnostics.
(I'm hoping it's not too difficult to implement)
The text was updated successfully, but these errors were encountered: