Fix closure recovery for missing block when return type is specified by compiler-errors · Pull Request #138749 · rust-lang/rust (original) (raw)

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