Files
rust/tests/ui/suggestions
Jonathan Brouwer 7174c100f4 Rollup merge of #153227 - kpreid:struct-missing-field, r=estebank
Don’t report missing fields in struct exprs with syntax errors.

@Noratrieb [told me](https://internals.rust-lang.org/t/custom-cargo-command-to-show-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`.)~~ The additional information is now stored as an additional variant of `ast::StructRest` / `hir::StructTailExpr`.

**Note to reviewers:** I recommend reviewing each commit separately, and in the case of the first one with indentation changes ignored.
2026-03-03 07:14:12 +01:00
..
2025-11-27 14:13:58 -05:00
2025-11-27 14:13:58 -05:00
2025-04-03 21:41:58 +00:00
2024-02-07 10:42:01 +08:00
2024-02-04 11:34:10 +08:00
2023-05-19 20:58:06 +02:00
2026-02-17 16:51:44 +00:00
2025-07-13 13:50:01 +00:00
2023-05-19 20:58:06 +02:00
2023-08-15 10:58:33 +00:00
2023-05-01 16:15:13 +08:00
2024-02-07 10:42:01 +08:00
2025-11-27 11:19:00 -05:00
2024-03-13 23:05:17 +00:00
2025-06-26 03:43:01 +00:00
2023-11-20 23:44:37 +00:00
2026-02-11 18:08:18 +09:00
2023-05-01 16:15:13 +08:00
2025-06-03 10:52:32 -07:00
2025-11-27 11:19:00 -05:00
2025-11-27 11:19:00 -05:00
2025-11-27 11:19:00 -05:00