1
Fork 0

Rollup merge of #119402 - est31:fix_if_guard_unused, r=compiler-errors

Also walk bindings created by if-let guards

This change makes the `unused_variables` lint pick up unused bindings created by if-let guards.

Fixes #119383
This commit is contained in:
Matthias Krüger 2023-12-29 11:19:28 +01:00 committed by GitHub
commit efd9fd66ba
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 26 additions and 0 deletions

View file

@ -1328,6 +1328,9 @@ impl<'a, 'tcx> Visitor<'tcx> for Liveness<'a, 'tcx> {
fn visit_arm(&mut self, arm: &'tcx hir::Arm<'tcx>) {
self.check_unused_vars_in_pat(arm.pat, None, None, |_, _, _, _| {});
if let Some(hir::Guard::IfLet(let_expr)) = arm.guard {
self.check_unused_vars_in_pat(let_expr.pat, None, None, |_, _, _, _| {});
}
intravisit::walk_arm(self, arm);
}
}