1
Fork 0

Rollup merge of #81236 - estebank:everybody-loop-now, r=oli-obk

Gracefully handle loop labels missing leading `'` in different positions

Fix #81192.

* Account for labels when suggesting `loop` instead of `while true`
* Suggest `'a` when given `a` only when appropriate
* Add loop head span to hir
* Tweak error for invalid `break expr`
* Add more misspelled label tests
* Avoid emitting redundant "unused label" lint
* Parse loop labels missing a leading `'`

Each commit can be reviewed in isolation.
This commit is contained in:
Mara Bos 2021-01-22 14:30:19 +00:00 committed by GitHub
commit 3682a06dcf
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
33 changed files with 523 additions and 139 deletions

View file

@ -266,7 +266,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
}
}
ExprKind::Ret(ref expr_opt) => self.check_expr_return(expr_opt.as_deref(), expr),
ExprKind::Loop(ref body, _, source) => {
ExprKind::Loop(ref body, _, source, _) => {
self.check_expr_loop(body, source, expected, expr)
}
ExprKind::Match(ref discrim, ref arms, match_src) => {

View file

@ -289,7 +289,7 @@ impl<'a, 'tcx> ExprUseVisitor<'a, 'tcx> {
| hir::ExprKind::ConstBlock(..)
| hir::ExprKind::Err => {}
hir::ExprKind::Loop(ref blk, _, _) => {
hir::ExprKind::Loop(ref blk, ..) => {
self.walk_block(blk);
}