Skip to content

Commit

Permalink
Fast reject for NeedsNonConstDrop
Browse files Browse the repository at this point in the history
  • Loading branch information
fee1-dead committed Sep 15, 2021
1 parent cdeba02 commit aade63a
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 aade63a

Please sign in to comment.