@@ -5,7 +5,7 @@ use rustc_middle::lint::in_external_macro;
55use rustc_middle:: ty:: subst:: GenericArgKind ;
66use rustc_session:: { declare_lint_pass, declare_tool_lint} ;
77
8- use crate :: utils:: { implements_trait , is_must_use_func_call, is_must_use_ty, match_type, paths, span_lint_and_help} ;
8+ use crate :: utils:: { is_must_use_func_call, is_must_use_ty, match_type, paths, span_lint_and_help} ;
99
1010declare_clippy_lint ! {
1111 /// **What it does:** Checks for `let _ = <expr>`
@@ -125,15 +125,6 @@ impl<'tcx> LateLintPass<'tcx> for LetUnderscore {
125125
126126 GenericArgKind :: Lifetime ( _) | GenericArgKind :: Const ( _) => false ,
127127 } ) ;
128- let implements_drop = cx. tcx. lang_items( ) . drop_trait( ) . map_or( false , |drop_trait|
129- init_ty. walk( ) . any( |inner| match inner. unpack( ) {
130- GenericArgKind :: Type ( inner_ty) => {
131- implements_trait( cx, inner_ty, drop_trait, & [ ] )
132- } ,
133-
134- GenericArgKind :: Lifetime ( _) | GenericArgKind :: Const ( _) => false ,
135- } )
136- ) ;
137128 if contains_sync_guard {
138129 span_lint_and_help(
139130 cx,
@@ -144,7 +135,7 @@ impl<'tcx> LateLintPass<'tcx> for LetUnderscore {
144135 "consider using an underscore-prefixed named \
145136 binding or dropping explicitly with `std::mem::drop`"
146137 )
147- } else if implements_drop {
138+ } else if init_ty . needs_drop ( cx . tcx , cx . param_env ) {
148139 span_lint_and_help(
149140 cx,
150141 LET_UNDERSCORE_DROP ,
0 commit comments