Rollup merge of #138749 - compiler-errors:closure-recovery, r=fmease
Fix closure recovery for missing block when return type is specified Firstly, fix the `is_array_like_block` condition to make sure we're actually recovering a mistyped *block* rather than some other delimited expression. This fixes #138748. Secondly, split out the recovery of missing braces on a closure body into a separate recovery. Right now, the suggestion `"you might have meant to write this as part of a block"` originates from `suggest_fixes_misparsed_for_loop_head`, which feels kinda brittle and coincidental since AFAICT that recovery wasn't ever really intended to fix this. We also can make this `MachineApplicable` in this case. Fixes #138748 r? `@fmease` or reassign if you're busy/don't wanna review this
This commit is contained in:
commit
0a579d5247
4 changed files with 101 additions and 16 deletions
|
@ -810,16 +810,16 @@ pub(crate) enum WrapInParentheses {
|
|||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(parse_array_brackets_instead_of_braces)]
|
||||
pub(crate) struct ArrayBracketsInsteadOfSpaces {
|
||||
pub(crate) struct ArrayBracketsInsteadOfBraces {
|
||||
#[primary_span]
|
||||
pub span: Span,
|
||||
#[subdiagnostic]
|
||||
pub sub: ArrayBracketsInsteadOfSpacesSugg,
|
||||
pub sub: ArrayBracketsInsteadOfBracesSugg,
|
||||
}
|
||||
|
||||
#[derive(Subdiagnostic)]
|
||||
#[multipart_suggestion(parse_suggestion, applicability = "maybe-incorrect")]
|
||||
pub(crate) struct ArrayBracketsInsteadOfSpacesSugg {
|
||||
pub(crate) struct ArrayBracketsInsteadOfBracesSugg {
|
||||
#[suggestion_part(code = "[")]
|
||||
pub left: Span,
|
||||
#[suggestion_part(code = "]")]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue