diff options
| author | flip1995 <philipp.krones@embecosm.com> | 2021-12-30 14:04:13 +0100 |
|---|---|---|
| committer | flip1995 <philipp.krones@embecosm.com> | 2021-12-30 14:17:53 +0100 |
| commit | e45842e3602e806345b3355ed0955e604daef49c (patch) | |
| tree | db4d1481f0b49bae4bdeedea435b5cfc0ceb6e38 /clippy_lints/src/shadow.rs | |
| parent | 01217f6f4c752700754e8e66eb02d763c4c55c72 (diff) | |
| parent | c1cd64b9c6b29ed2a577fc174a50c76267a966e2 (diff) | |
| download | rust-e45842e3602e806345b3355ed0955e604daef49c.tar.gz rust-e45842e3602e806345b3355ed0955e604daef49c.zip | |
Merge remote-tracking branch 'upstream/master' into rustup
Diffstat (limited to 'clippy_lints/src/shadow.rs')
| -rw-r--r-- | clippy_lints/src/shadow.rs | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/clippy_lints/src/shadow.rs b/clippy_lints/src/shadow.rs index f6880af0cab..ce05c5a6164 100644 --- a/clippy_lints/src/shadow.rs +++ b/clippy_lints/src/shadow.rs @@ -5,7 +5,7 @@ use rustc_data_structures::fx::FxHashMap; use rustc_hir::def::Res; use rustc_hir::def_id::LocalDefId; use rustc_hir::hir_id::ItemLocalId; -use rustc_hir::{Block, Body, BodyOwnerKind, Expr, ExprKind, HirId, Node, Pat, PatKind, QPath, UnOp}; +use rustc_hir::{Block, Body, BodyOwnerKind, Expr, ExprKind, HirId, Let, Node, Pat, PatKind, QPath, UnOp}; use rustc_lint::{LateContext, LateLintPass}; use rustc_session::{declare_tool_lint, impl_lint_pass}; use rustc_span::{Span, Symbol}; @@ -220,14 +220,14 @@ fn is_self_shadow(cx: &LateContext<'_>, pat: &Pat<'_>, mut expr: &Expr<'_>, hir_ } } -/// Finds the "init" expression for a pattern: `let <pat> = <init>;` or +/// Finds the "init" expression for a pattern: `let <pat> = <init>;` (or `if let`) or /// `match <init> { .., <pat> => .., .. }` fn find_init<'tcx>(cx: &LateContext<'tcx>, hir_id: HirId) -> Option<&'tcx Expr<'tcx>> { for (_, node) in cx.tcx.hir().parent_iter(hir_id) { let init = match node { Node::Arm(_) | Node::Pat(_) => continue, Node::Expr(expr) => match expr.kind { - ExprKind::Match(e, _, _) => Some(e), + ExprKind::Match(e, _, _) | ExprKind::Let(&Let { init: e, .. }) => Some(e), _ => None, }, Node::Local(local) => local.init, |
