about summary refs log tree commit diff
path: root/compiler/rustc_llvm/llvm-wrapper/CoverageMappingWrapper.cpp
diff options
context:
space:
mode:
authorManish Goregaokar <manishsmail@gmail.com>2021-09-10 08:23:17 -0700
committerGitHub <noreply@github.com>2021-09-10 08:23:17 -0700
commitdc003dd49e5599a0de22653d6bd4aaa8d460234e (patch)
tree8d2107035fa5a5d2017b7da623618059dc2a6b6d /compiler/rustc_llvm/llvm-wrapper/CoverageMappingWrapper.cpp
parent358a01829229427d9efaf89a05881a0ef86e9e8a (diff)
parentb21425de3c6be4264b875e68c8a28b424c27b8c4 (diff)
downloadrust-dc003dd49e5599a0de22653d6bd4aaa8d460234e.tar.gz
rust-dc003dd49e5599a0de22653d6bd4aaa8d460234e.zip
Rollup merge of #88546 - scrabsha:scrabsha/closure-missing-braces, r=estebank
Emit proper errors when on missing closure braces

This commit focuses on emitting clean errors for the following syntax
error:

```
Some(42).map(|a|
    dbg!(a);
    a
);
```

Previous implementation tried to recover after parsing the closure body
(the `dbg` expression) by replacing the next `;` with a `,`, which made
the next expression belong to the next function argument. As such, the
following errors were emitted (among others):
  - the semicolon token was not expected,
  - a is not in scope,
  - Option::map is supposed to take one argument, not two.

This commit allows us to gracefully handle this situation by adding
giving the parser the ability to remember when it has just parsed a
closure body inside a function call. When this happens, we can treat the
unexpected `;` specifically and try to parse as much statements as
possible in order to eat the whole block. When we can't parse statements
anymore, we generate a clean error indicating that the braces are
missing, and return an ExprKind::Err.

Closes #88065.

r? `@estebank`
Diffstat (limited to 'compiler/rustc_llvm/llvm-wrapper/CoverageMappingWrapper.cpp')
0 files changed, 0 insertions, 0 deletions