File tree Expand file tree Collapse file tree 1 file changed +11
-1
lines changed
compiler/rustc_const_eval/src/transform/check_consts Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -111,7 +111,17 @@ impl Qualif for NeedsNonConstDrop {
111111 qualifs.needs_drop
112112 }
113113
114- fn in_any_value_of_ty ( cx : & ConstCx < ' _ , ' tcx > , ty : Ty < ' tcx > ) -> bool {
114+ fn in_any_value_of_ty(cx: &ConstCx<'_, 'tcx>, mut ty: Ty<'tcx>) -> bool {
115+ // Avoid selecting for simple cases.
116+ match ty::util::needs_drop_components(ty, &cx.tcx.data_layout).as_deref() {
117+ Ok([]) => return false,
118+ Err(ty::util::AlwaysRequiresDrop) => return true,
119+ // If we've got a single component, select with that
120+ // to increase the chance that we hit the selection cache.
121+ Ok([t]) => ty = t,
122+ Ok([..]) => {}
123+ }
124+
115125 let drop_trait = if let Some(did) = cx.tcx.lang_items().drop_trait() {
116126 did
117127 } else {
You can’t perform that action at this time.
0 commit comments