diff options
| author | Jason Newcomb <jsnewcomb@pm.me> | 2022-10-08 11:23:05 -0400 |
|---|---|---|
| committer | Jason Newcomb <jsnewcomb@pm.me> | 2022-10-08 11:23:05 -0400 |
| commit | 39a7d000b640523772ea709bc85d2c9460cf07bf (patch) | |
| tree | 72d7c5175f27f03e210fd149755467314d9cdfd0 | |
| parent | 2c8e473ffea22fdf9ffbecb53c1c7288d38fe923 (diff) | |
| download | rust-39a7d000b640523772ea709bc85d2c9460cf07bf.tar.gz rust-39a7d000b640523772ea709bc85d2c9460cf07bf.zip | |
Don't suggest moving tuple structs with a significant drop to late evaluation.
| -rw-r--r-- | clippy_utils/src/eager_or_lazy.rs | 2 | ||||
| -rw-r--r-- | tests/ui/or_fun_call.fixed | 11 | ||||
| -rw-r--r-- | tests/ui/or_fun_call.rs | 11 |
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() {} |
