rust/compiler/rustc_parse/src/parser
Matthias Krüger 260e04879e
Rollup merge of #107190 - fmease:fix-81698, r=compiler-errors
Recover from more const arguments that are not wrapped in curly braces

Recover from some array, borrow, tuple & arithmetic expressions in const argument positions that lack curly braces and provide a suggestion to fix the issue continuing where #92884 left off. Examples of such expressions: `[]`, `[0]`, `[1, 2]`, `[0; 0xff]`, `&9`, `("", 0)` and `(1 + 2) * 3` (we previously did not recover from them).

I am not entirely happy with my current solution because the code that recovers from `[0]` (coinciding with a malformed slice type) and `[0; 0]` (coinciding with a malformed array type) is quite fragile as the aforementioned snippets are actually successfully parsed as types by `parse_ty` since it itself already recovers from them (returning `[⟨error⟩]` and `[⟨error⟩; 0]` respectively) meaning I have to manually look for `TyKind::Err`s and construct a separate diagnostic for the suggestion to attach to (thereby emitting two diagnostics in total).

Fixes #81698.
`@rustbot` label A-diagnostics
r? diagnostics
2023-01-28 05:20:17 +01:00
..
attr_wrapper.rs compiler: remove unnecessary imports and qualified paths 2022-12-10 18:45:34 +01:00
attr.rs compiler: remove unnecessary imports and qualified paths 2022-12-10 18:45:34 +01:00
diagnostics.rs Rollup merge of #107190 - fmease:fix-81698, r=compiler-errors 2023-01-28 05:20:17 +01:00
expr.rs Add suggestion to remove if in let...else block 2023-01-23 20:33:04 -08:00
generics.rs parser: recover from where clauses placed before tuple struct bodies 2023-01-11 17:54:48 +01:00
item.rs Auto merge of #106537 - fmease:recover-where-clause-before-tuple-struct-body, r=estebank 2023-01-12 02:16:16 +00:00
mod.rs Remove double spaces after dots in comments 2023-01-17 08:09:33 +00:00
nonterminal.rs rustc_parse: remove ref patterns 2022-11-22 18:49:16 +00:00
pat.rs Teach parser to understand fake anonymous enum syntax 2023-01-17 01:58:32 +00:00
path.rs recover more unbraced const args 2023-01-27 19:26:04 +01:00
stmt.rs Make LhsExpr::AlreadyParsed a named struct 2023-01-14 11:28:14 +00:00
ty.rs Rollup merge of #106960 - estebank:parse-anon-enums, r=cjgillot 2023-01-26 06:15:24 +01:00