File tree 1 file changed +11
-1
lines changed
compiler/rustc_const_eval/src/transform/check_consts
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 {
111
111
qualifs. needs_drop
112
112
}
113
113
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
+
115
125
let drop_trait = if let Some ( did) = cx. tcx . lang_items ( ) . drop_trait ( ) {
116
126
did
117
127
} else {
You can’t perform that action at this time.
0 commit comments