@@ -328,6 +328,23 @@ impl<'a, 'tcx> ty::Lift<'tcx> for SelectionCandidate<'a> {
328
328
}
329
329
}
330
330
331
+ EnumTypeFoldableImpl ! {
332
+ impl <' tcx> TypeFoldable <' tcx> for SelectionCandidate <' tcx> {
333
+ ( SelectionCandidate :: BuiltinCandidate ) { has_nested } ,
334
+ ( SelectionCandidate :: ParamCandidate ) ( poly_trait_ref) ,
335
+ ( SelectionCandidate :: ImplCandidate ) ( def_id) ,
336
+ ( SelectionCandidate :: AutoImplCandidate ) ( def_id) ,
337
+ ( SelectionCandidate :: ProjectionCandidate ) ,
338
+ ( SelectionCandidate :: ClosureCandidate ) ,
339
+ ( SelectionCandidate :: GeneratorCandidate ) ,
340
+ ( SelectionCandidate :: FnPointerCandidate ) ,
341
+ ( SelectionCandidate :: TraitAliasCandidate ) ( def_id) ,
342
+ ( SelectionCandidate :: ObjectCandidate ) ,
343
+ ( SelectionCandidate :: BuiltinObjectCandidate ) ,
344
+ ( SelectionCandidate :: BuiltinUnsizeCandidate ) ,
345
+ }
346
+ }
347
+
331
348
struct SelectionCandidateSet < ' tcx > {
332
349
// a list of candidates that definitely apply to the current
333
350
// obligation (meaning: types unify).
@@ -818,27 +835,25 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
818
835
819
836
ty:: Predicate :: ConstEvaluatable ( def_id, substs) => {
820
837
let tcx = self . tcx ( ) ;
821
- match tcx. lift_to_global ( & ( obligation. param_env , substs) ) {
822
- Some ( ( param_env, substs) ) => {
823
- let instance =
824
- ty:: Instance :: resolve ( tcx. global_tcx ( ) , param_env, def_id, substs) ;
825
- if let Some ( instance) = instance {
826
- let cid = GlobalId {
827
- instance,
828
- promoted : None ,
829
- } ;
830
- match self . tcx ( ) . const_eval ( param_env. and ( cid) ) {
831
- Ok ( _) => Ok ( EvaluatedToOk ) ,
832
- Err ( _) => Ok ( EvaluatedToErr ) ,
833
- }
834
- } else {
835
- Ok ( EvaluatedToErr )
838
+ if !( obligation. param_env , substs) . has_local_value ( ) {
839
+ let param_env = obligation. param_env ;
840
+ let instance =
841
+ ty:: Instance :: resolve ( tcx, param_env, def_id, substs) ;
842
+ if let Some ( instance) = instance {
843
+ let cid = GlobalId {
844
+ instance,
845
+ promoted : None ,
846
+ } ;
847
+ match self . tcx ( ) . const_eval ( param_env. and ( cid) ) {
848
+ Ok ( _) => Ok ( EvaluatedToOk ) ,
849
+ Err ( _) => Ok ( EvaluatedToErr ) ,
836
850
}
851
+ } else {
852
+ Ok ( EvaluatedToErr )
837
853
}
838
- None => {
839
- // Inference variables still left in param_env or substs.
840
- Ok ( EvaluatedToAmbig )
841
- }
854
+ } else {
855
+ // Inference variables still left in param_env or substs.
856
+ Ok ( EvaluatedToAmbig )
842
857
}
843
858
}
844
859
}
@@ -1172,7 +1187,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
1172
1187
}
1173
1188
1174
1189
if self . can_use_global_caches ( param_env) {
1175
- if let Some ( trait_ref) = self . tcx ( ) . lift_to_global ( & trait_ref ) {
1190
+ if ! trait_ref. has_local_value ( ) {
1176
1191
debug ! (
1177
1192
"insert_evaluation_cache(trait_ref={:?}, candidate={:?}) global" ,
1178
1193
trait_ref, result,
@@ -1645,8 +1660,8 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
1645
1660
if let Err ( Overflow ) = candidate {
1646
1661
// Don't cache overflow globally; we only produce this
1647
1662
// in certain modes.
1648
- } else if let Some ( trait_ref) = tcx . lift_to_global ( & trait_ref ) {
1649
- if let Some ( candidate) = tcx . lift_to_global ( & candidate ) {
1663
+ } else if ! trait_ref. has_local_value ( ) {
1664
+ if ! candidate. has_local_value ( ) {
1650
1665
debug ! (
1651
1666
"insert_candidate_cache(trait_ref={:?}, candidate={:?}) global" ,
1652
1667
trait_ref, candidate,
0 commit comments