about summary refs log tree commit diff
path: root/clippy_lints/src/let_underscore.rs
diff options
context:
space:
mode:
authorEduard Burtescu <edy.burt@gmail.com>2020-04-07 19:53:56 +0000
committerEduard Burtescu <edy.burt@gmail.com>2020-04-07 19:53:56 +0000
commit2ad4d6a057e17c727ab007faed346d83fc1f33d3 (patch)
tree018166c2afd8723958ea5fe0b028acb8c321a804 /clippy_lints/src/let_underscore.rs
parent89e14d201db8c8dc49fab4c1d17d6546b00817ae (diff)
rustup: update for the new Ty::walk interface.
Diffstat (limited to 'clippy_lints/src/let_underscore.rs')
-rw-r--r--clippy_lints/src/let_underscore.rs10
1 files changed, 8 insertions, 2 deletions
diff --git a/clippy_lints/src/let_underscore.rs b/clippy_lints/src/let_underscore.rs
index a68f7edd837..da83b1f3ce6 100644
--- a/clippy_lints/src/let_underscore.rs
+++ b/clippy_lints/src/let_underscore.rs
@@ -2,6 +2,7 @@ use if_chain::if_chain;
 use rustc_hir::{Local, PatKind};
 use rustc_lint::{LateContext, LateLintPass};
 use rustc_middle::lint::in_external_macro;
+use rustc_middle::ty::subst::GenericArgKind;
 use rustc_session::{declare_lint_pass, declare_tool_lint};
 
 use crate::utils::{is_must_use_func_call, is_must_use_ty, match_type, paths, span_lint_and_help};
@@ -75,8 +76,13 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for LetUnderscore {
             if let PatKind::Wild = local.pat.kind;
             if let Some(ref init) = local.init;
             then {
-                let check_ty = |ty| SYNC_GUARD_PATHS.iter().any(|path| match_type(cx, ty, path));
-                if cx.tables.expr_ty(init).walk().any(check_ty) {
+                let init_ty = cx.tables.expr_ty(init);
+                let contains_sync_guard = init_ty.walk().any(|inner| match inner.unpack() {
+                    GenericArgKind::Type(inner_ty) => SYNC_GUARD_PATHS.iter().any(|path| match_type(cx, inner_ty, path)),
+
+                    GenericArgKind::Lifetime(_) | GenericArgKind::Const(_) => false,
+                });
+                if contains_sync_guard {
                     span_lint_and_help(
                         cx,
                         LET_UNDERSCORE_LOCK,