1
Fork 0

Rollup merge of #92402 - pr2502:while-let-typo, r=oli-obk

Suggest while let x = y when encountering while x = y

Extends #75931 to also detect where the `let` might be missing from `while let` expressions.
This commit is contained in:
Matthias Krüger 2022-01-03 14:44:18 +01:00 committed by GitHub
commit 0335b7bca9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 56 additions and 0 deletions

View file

@ -2379,7 +2379,9 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> {
ExprKind::While(ref cond, ref block, label) => {
self.with_resolved_label(label, expr.id, |this| {
this.with_rib(ValueNS, NormalRibKind, |this| {
let old = this.diagnostic_metadata.in_if_condition.replace(cond);
this.visit_expr(cond);
this.diagnostic_metadata.in_if_condition = old;
this.visit_block(block);
})
});