]> git.lizzy.rs Git - rust.git/commitdiff
Rollup merge of #99030 - rust-lang:notriddle/field-recovery, r=petrochenkov
authorDylan DPC <99973273+Dylan-DPC@users.noreply.github.com>
Wed, 13 Jul 2022 14:02:35 +0000 (19:32 +0530)
committerGitHub <noreply@github.com>
Wed, 13 Jul 2022 14:02:35 +0000 (19:32 +0530)
diagnostics: error messages when struct literals fail to parse

If an expression is supplied where a field is expected, the parser can become convinced that it's a shorthand field syntax when it's not.

This PR addresses it by explicitly recording the permitted `:` token immediately after the identifier, and also adds a suggestion to insert the name of the field if it looks like a complex expression.

Fixes #98917

1  2 
compiler/rustc_parse/src/parser/expr.rs