about summary refs log tree commit diff
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2022-10-10 12:29:15 +0000
committerbors <bors@rust-lang.org>2022-10-10 12:29:15 +0000
commitcf72565a12c982f577ca4394c3b80edb89f6c6d3 (patch)
treecef7d8e4cfe94942ac48d50e68df597eb2c35374
parent272bbfb857650e0d3d05dd83a5ce1a522c94b4bd (diff)
parent39a7d000b640523772ea709bc85d2c9460cf07bf (diff)
downloadrust-cf72565a12c982f577ca4394c3b80edb89f6c6d3.tar.gz
rust-cf72565a12c982f577ca4394c3b80edb89f6c6d3.zip
Auto merge of #9610 - Jarcho:fix-9608, r=Alexendoo
Don't suggest moving tuple structs with a significant drop to late evaluation

fixes #9608

changelog: Don't suggest moving tuple structs with a significant drop to late evaluation
-rw-r--r--clippy_utils/src/eager_or_lazy.rs2
-rw-r--r--tests/ui/or_fun_call.fixed11
-rw-r--r--tests/ui/or_fun_call.rs11
3 files changed, 23 insertions, 1 deletions
diff --git a/clippy_utils/src/eager_or_lazy.rs b/clippy_utils/src/eager_or_lazy.rs
index 8724a4cd651..95b3e651e2b 100644
--- a/clippy_utils/src/eager_or_lazy.rs
+++ b/clippy_utils/src/eager_or_lazy.rs
@@ -120,7 +120,7 @@ fn expr_eagerness<'tcx>(cx: &LateContext<'tcx>, e: &'tcx Expr<'_>) -> EagernessS
                             .expr_ty(e)
                             .has_significant_drop(self.cx.tcx, self.cx.param_env)
                         {
-                            self.eagerness = Lazy;
+                            self.eagerness = ForceNoChange;
                             return;
                         }
                     },
diff --git a/tests/ui/or_fun_call.fixed b/tests/ui/or_fun_call.fixed
index 896430780ea..23b1aa8bebd 100644
--- a/tests/ui/or_fun_call.fixed
+++ b/tests/ui/or_fun_call.fixed
@@ -225,4 +225,15 @@ mod issue8239 {
     }
 }
 
+mod issue9608 {
+    fn sig_drop() {
+        enum X {
+            X(std::fs::File),
+            Y(u32),
+        }
+
+        let _ = None.unwrap_or(X::Y(0));
+    }
+}
+
 fn main() {}
diff --git a/tests/ui/or_fun_call.rs b/tests/ui/or_fun_call.rs
index 2473163d4fd..039998f22dd 100644
--- a/tests/ui/or_fun_call.rs
+++ b/tests/ui/or_fun_call.rs
@@ -225,4 +225,15 @@ mod issue8239 {
     }
 }
 
+mod issue9608 {
+    fn sig_drop() {
+        enum X {
+            X(std::fs::File),
+            Y(u32),
+        }
+
+        let _ = None.unwrap_or(X::Y(0));
+    }
+}
+
 fn main() {}