Skip to content

Commit cf72565

Browse files
committed
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
2 parents 272bbfb + 39a7d00 commit cf72565

File tree

3 files changed

+23
-1
lines changed

3 files changed

+23
-1
lines changed

clippy_utils/src/eager_or_lazy.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ fn expr_eagerness<'tcx>(cx: &LateContext<'tcx>, e: &'tcx Expr<'_>) -> EagernessS
120120
.expr_ty(e)
121121
.has_significant_drop(self.cx.tcx, self.cx.param_env)
122122
{
123-
self.eagerness = Lazy;
123+
self.eagerness = ForceNoChange;
124124
return;
125125
}
126126
},

tests/ui/or_fun_call.fixed

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,4 +225,15 @@ mod issue8239 {
225225
}
226226
}
227227

228+
mod issue9608 {
229+
fn sig_drop() {
230+
enum X {
231+
X(std::fs::File),
232+
Y(u32),
233+
}
234+
235+
let _ = None.unwrap_or(X::Y(0));
236+
}
237+
}
238+
228239
fn main() {}

tests/ui/or_fun_call.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,4 +225,15 @@ mod issue8239 {
225225
}
226226
}
227227

228+
mod issue9608 {
229+
fn sig_drop() {
230+
enum X {
231+
X(std::fs::File),
232+
Y(u32),
233+
}
234+
235+
let _ = None.unwrap_or(X::Y(0));
236+
}
237+
}
238+
228239
fn main() {}

0 commit comments

Comments
 (0)