Skip to content

Commit

Permalink
Auto merge of rust-lang#88965 - fee1-dead:const-drop-1, r=oli-obk
Browse files Browse the repository at this point in the history
Fast reject for NeedsNonConstDrop

Hopefully fixes the regression in rust-lang#88558.

I've always wanted to help with the performance of rustc, but it doesn't feel the same when you are fixing a regression caused by your own PR...

r? `@oli-obk`
  • Loading branch information
bors committed Sep 18, 2021
2 parents a58db2e + aade63a commit 8e398f5
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion compiler/rustc_const_eval/src/transform/check_consts/qualifs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,17 @@ impl Qualif for NeedsNonConstDrop {
qualifs.needs_drop
}

fn in_any_value_of_ty(cx: &ConstCx<'_, 'tcx>, ty: Ty<'tcx>) -> bool {
fn in_any_value_of_ty(cx: &ConstCx<'_, 'tcx>, mut ty: Ty<'tcx>) -> bool {
// Avoid selecting for simple cases.
match ty::util::needs_drop_components(ty, &cx.tcx.data_layout).as_deref() {
Ok([]) => return false,
Err(ty::util::AlwaysRequiresDrop) => return true,
// If we've got a single component, select with that
// to increase the chance that we hit the selection cache.
Ok([t]) => ty = t,
Ok([..]) => {}
}

let drop_trait = if let Some(did) = cx.tcx.lang_items().drop_trait() {
did
} else {
Expand Down

0 comments on commit 8e398f5

Please sign in to comment.