Skip to content

Commit

Permalink
Auto merge of #9610 - Jarcho:fix-9608, r=Alexendoo
Browse files Browse the repository at this point in the history
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
  • Loading branch information
bors committed Oct 10, 2022
2 parents 272bbfb + 39a7d00 commit cf72565
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 1 deletion.
2 changes: 1 addition & 1 deletion clippy_utils/src/eager_or_lazy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
},
Expand Down
11 changes: 11 additions & 0 deletions tests/ui/or_fun_call.fixed
Original file line number Diff line number Diff line change
Expand Up @@ -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() {}
11 changes: 11 additions & 0 deletions tests/ui/or_fun_call.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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() {}

0 comments on commit cf72565

Please sign in to comment.