{
"$type": "site.standard.document",
"bskyPostRef": {
"cid": "bafyreichkhol346725lj7cjpamemnyncrt6myam6yrvjta46qirr6nlroa",
"uri": "at://did:plc:ivbknywyskln22er3nkssdhl/app.bsky.feed.post/3mfx7nciymvm2"
},
"path": "/t/custom-cargo-command-to-show-only-errors-avoid-setting-rustflags-every-time/24032#post_15",
"publishedAt": "2026-02-28T17:21:13.000Z",
"site": "https://internals.rust-lang.org",
"tags": [
"github.com/rust-lang/rust",
"Don’t report missing fields in struct exprs with syntax errors. (#153227)",
"kpreid",
"+232 -95",
"told me",
"@Noratrieb"
],
"textContent": "Well then, one followup error that recently annoyed me came to mind, so I tried writing a fix for it:\n\ngithub.com/rust-lang/rust\n\n#### Don’t report missing fields in struct exprs with syntax errors. (#153227)\n\n`main` ← `kpreid:struct-missing-field`\n\nopened 05:18PM - 28 Feb 26 UTC\n\n kpreid \n\n +232 -95 \n\n@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`.)",
"title": "Custom Cargo Command to Show Only Errors (Avoid Setting RustFLAGS Every Time)"
}