From ac5e9c8d2691da5a3872a8eec97ce694193c1e5c Mon Sep 17 00:00:00 2001
From: Cameron Steffen <cam.steffen94@gmail.com>
Date: Fri, 5 Feb 2021 14:45:24 -0600
Subject: [PATCH 1/2] Fix let_underscore_drop implements Drop logic

This fixes false positives and false negatives.
---
 clippy_lints/src/let_underscore.rs | 13 ++-----------
 tests/ui/let_underscore_drop.rs    |  8 ++++++++
 2 files changed, 10 insertions(+), 11 deletions(-)

diff --git a/clippy_lints/src/let_underscore.rs b/clippy_lints/src/let_underscore.rs
index 6a5a77f8690..7e96dfcc7da 100644
--- a/clippy_lints/src/let_underscore.rs
+++ b/clippy_lints/src/let_underscore.rs
@@ -5,7 +5,7 @@ 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::{implements_trait, is_must_use_func_call, is_must_use_ty, match_type, paths, span_lint_and_help};
+use crate::utils::{is_must_use_func_call, is_must_use_ty, match_type, paths, span_lint_and_help};
 
 declare_clippy_lint! {
     /// **What it does:** Checks for `let _ = <expr>`
@@ -125,15 +125,6 @@ impl<'tcx> LateLintPass<'tcx> for LetUnderscore {
 
                     GenericArgKind::Lifetime(_) | GenericArgKind::Const(_) => false,
                 });
-                let implements_drop = cx.tcx.lang_items().drop_trait().map_or(false, |drop_trait|
-                    init_ty.walk().any(|inner| match inner.unpack() {
-                        GenericArgKind::Type(inner_ty) => {
-                            implements_trait(cx, inner_ty, drop_trait, &[])
-                        },
-
-                        GenericArgKind::Lifetime(_) | GenericArgKind::Const(_) => false,
-                    })
-                );
                 if contains_sync_guard {
                     span_lint_and_help(
                         cx,
@@ -144,7 +135,7 @@ impl<'tcx> LateLintPass<'tcx> for LetUnderscore {
                         "consider using an underscore-prefixed named \
                             binding or dropping explicitly with `std::mem::drop`"
                     )
-                } else if implements_drop {
+                } else if init_ty.needs_drop(cx.tcx, cx.param_env) {
                     span_lint_and_help(
                         cx,
                         LET_UNDERSCORE_DROP,
diff --git a/tests/ui/let_underscore_drop.rs b/tests/ui/let_underscore_drop.rs
index 98593edb9c5..50744f81c3c 100644
--- a/tests/ui/let_underscore_drop.rs
+++ b/tests/ui/let_underscore_drop.rs
@@ -16,4 +16,12 @@ fn main() {
     let _ = Box::new(());
     let _ = Droppable;
     let _ = Some(Droppable);
+
+    // no lint for reference
+    let _ = droppable_ref();
+}
+
+#[must_use]
+fn droppable_ref() -> &'static mut Droppable {
+    unimplemented!()
 }

From 40ce05654be9f4f6fb80e295f3eb05bee211cfc7 Mon Sep 17 00:00:00 2001
From: Cameron Steffen <cam.steffen94@gmail.com>
Date: Fri, 5 Feb 2021 14:55:09 -0600
Subject: [PATCH 2/2] Eat dogfood

---
 clippy_dev/src/serve.rs       | 2 +-
 clippy_lints/src/macro_use.rs | 2 +-
 src/main.rs                   | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/clippy_dev/src/serve.rs b/clippy_dev/src/serve.rs
index faa94859601..d13c27a1957 100644
--- a/clippy_dev/src/serve.rs
+++ b/clippy_dev/src/serve.rs
@@ -34,7 +34,7 @@ pub fn run(port: u16, lint: Option<&str>) -> ! {
                 // Give some time for python to start
                 thread::sleep(Duration::from_millis(500));
                 // Launch browser after first export.py has completed and http.server is up
-                let _ = opener::open(url);
+                let _result = opener::open(url);
             });
         }
         thread::sleep(Duration::from_millis(1000));
diff --git a/clippy_lints/src/macro_use.rs b/clippy_lints/src/macro_use.rs
index bb52888883a..40f04bd677d 100644
--- a/clippy_lints/src/macro_use.rs
+++ b/clippy_lints/src/macro_use.rs
@@ -160,7 +160,7 @@ impl<'tcx> LateLintPass<'tcx> for MacroUseImports {
             let found_idx = self.mac_refs.iter().position(|mac| import.ends_with(&mac.name));
 
             if let Some(idx) = found_idx {
-                let _ = self.mac_refs.remove(idx);
+                self.mac_refs.remove(idx);
                 let seg = import.split("::").collect::<Vec<_>>();
 
                 match seg.as_slice() {
diff --git a/src/main.rs b/src/main.rs
index ea06743394d..b4423ce9ec7 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -195,7 +195,7 @@ mod tests {
     #[should_panic]
     fn fix_without_unstable() {
         let args = "cargo clippy --fix".split_whitespace().map(ToString::to_string);
-        let _ = ClippyCmd::new(args);
+        ClippyCmd::new(args);
     }
 
     #[test]