Custom Cargo Command to Show Only Errors (Avoid Setting RustFLAGS Every Time)
Well then, one followup error that recently annoyed me came to mind, so I tried writing a fix for it:
github.com/rust-lang/rust
Don’t report missing fields in struct exprs with syntax errors. (#153227)
main ← kpreid:struct-missing-field
opened 05:18PM - 28 Feb 26 UTC
kpreid
+232 -95
@Noratrieb told mehow-only-errors-avoid-setting-rustflags-every-time/24032/7?u=kpreid) that “it is a bug if this recovery causes follow-up errors that would not be there if the user fixed the first error.” So, here’s a contribution to hide a follow-up error that annoyed me recently. Specifically, if the user writes a struct literal with a syntax error, such as rust StructName { foo: 1 bar: 2 } the compiler will no longer report that the field bar is missing in addition to the syntax error. This is my first time attempting any change to the parser or AST; please let me know if there is a better way to do what I’ve done here. The part I’m least happy with is the blast radius of adding another field to hir::ExprKind::Struct, but this seems to be in line with the style of the rest of the code. (If this were my own code, I would consider changing hir::ExprKind::Struct to a nested struct, the same way it is in ast::ExprKind.)
Discussion in the ATmosphere