X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;f=src%2Ftools%2Fclippy%2Fclippy_lints%2Fsrc%2Fshadow.rs;h=7da47ee4ff94b892c3ef369ccbfb0f8c028f6b05;hb=8afb305e7200b05dacf6129e2c10575f4ca6ebb0;hp=4780249bcb8e3fe4840622eab86bb2dd034f7c40;hpb=9672b5e95c520774cc17bffc7031c80a1bcf4b4c;p=rust.git diff --git a/src/tools/clippy/clippy_lints/src/shadow.rs b/src/tools/clippy/clippy_lints/src/shadow.rs index 4780249bcb8..901c0a65d7f 100644 --- a/src/tools/clippy/clippy_lints/src/shadow.rs +++ b/src/tools/clippy/clippy_lints/src/shadow.rs @@ -96,10 +96,10 @@ declare_lint_pass!(Shadow => [SHADOW_SAME, SHADOW_REUSE, SHADOW_UNRELATED]); -impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Shadow { +impl<'tcx> LateLintPass<'tcx> for Shadow { fn check_fn( &mut self, - cx: &LateContext<'a, 'tcx>, + cx: &LateContext<'tcx>, _: FnKind<'tcx>, decl: &'tcx FnDecl<'_>, body: &'tcx Body<'_>, @@ -113,7 +113,7 @@ fn check_fn( } } -fn check_fn<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, decl: &'tcx FnDecl<'_>, body: &'tcx Body<'_>) { +fn check_fn<'tcx>(cx: &LateContext<'tcx>, decl: &'tcx FnDecl<'_>, body: &'tcx Body<'_>) { let mut bindings = Vec::with_capacity(decl.inputs.len()); for arg in iter_input_pats(decl, body) { if let PatKind::Binding(.., ident, _) = arg.pat.kind { @@ -123,7 +123,7 @@ fn check_fn<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, decl: &'tcx FnDecl<'_>, body: check_expr(cx, &body.value, &mut bindings); } -fn check_block<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, block: &'tcx Block<'_>, bindings: &mut Vec<(Name, Span)>) { +fn check_block<'tcx>(cx: &LateContext<'tcx>, block: &'tcx Block<'_>, bindings: &mut Vec<(Name, Span)>) { let len = bindings.len(); for stmt in block.stmts { match stmt.kind { @@ -138,7 +138,7 @@ fn check_block<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, block: &'tcx Block<'_>, bin bindings.truncate(len); } -fn check_local<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, local: &'tcx Local<'_>, bindings: &mut Vec<(Name, Span)>) { +fn check_local<'tcx>(cx: &LateContext<'tcx>, local: &'tcx Local<'_>, bindings: &mut Vec<(Name, Span)>) { if in_external_macro(cx.sess(), local.span) { return; } @@ -163,20 +163,13 @@ fn check_local<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, local: &'tcx Local<'_>, bin } } -fn is_binding(cx: &LateContext<'_, '_>, pat_id: HirId) -> bool { - let var_ty = cx.tables().node_type_opt(pat_id); - if let Some(var_ty) = var_ty { - match var_ty.kind { - ty::Adt(..) => false, - _ => true, - } - } else { - false - } +fn is_binding(cx: &LateContext<'_>, pat_id: HirId) -> bool { + let var_ty = cx.typeck_results().node_type_opt(pat_id); + var_ty.map_or(false, |var_ty| !matches!(var_ty.kind, ty::Adt(..))) } -fn check_pat<'a, 'tcx>( - cx: &LateContext<'a, 'tcx>, +fn check_pat<'tcx>( + cx: &LateContext<'tcx>, pat: &'tcx Pat<'_>, init: Option<&'tcx Expr<'_>>, span: Span, @@ -259,8 +252,8 @@ fn check_pat<'a, 'tcx>( } } -fn lint_shadow<'a, 'tcx>( - cx: &LateContext<'a, 'tcx>, +fn lint_shadow<'tcx>( + cx: &LateContext<'tcx>, name: Name, span: Span, pattern_span: Span, @@ -326,7 +319,7 @@ fn lint_shadow<'a, 'tcx>( } } -fn check_expr<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr<'_>, bindings: &mut Vec<(Name, Span)>) { +fn check_expr<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>, bindings: &mut Vec<(Name, Span)>) { if in_external_macro(cx.sess(), expr.span) { return; } @@ -362,7 +355,7 @@ fn check_expr<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr<'_>, bindin } } -fn check_ty<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, ty: &'tcx Ty<'_>, bindings: &mut Vec<(Name, Span)>) { +fn check_ty<'tcx>(cx: &LateContext<'tcx>, ty: &'tcx Ty<'_>, bindings: &mut Vec<(Name, Span)>) { match ty.kind { TyKind::Slice(ref sty) => check_ty(cx, sty, bindings), TyKind::Array(ref fty, ref anon_const) => {