@@ -58,19 +58,6 @@ pub struct FulfillmentContext<'tcx> {
5858
5959 relationships : FxHashMap < ty:: TyVid , ty:: FoundRelationships > ,
6060
61- // Should this fulfillment context register type-lives-for-region
62- // obligations on its parent infcx? In some cases, region
63- // obligations are either already known to hold (normalization) or
64- // hopefully verified elsewhere (type-impls-bound), and therefore
65- // should not be checked.
66- //
67- // Note that if we are normalizing a type that we already
68- // know is well-formed, there should be no harm setting this
69- // to true - all the region variables should be determinable
70- // using the RFC 447 rules, which don't depend on
71- // type-lives-for-region constraints, and because the type
72- // is well-formed, the constraints should hold.
73- register_region_obligations : bool ,
7461 // Is it OK to register obligations into this infcx inside
7562 // an infcx snapshot?
7663 //
@@ -103,7 +90,6 @@ impl<'a, 'tcx> FulfillmentContext<'tcx> {
10390 FulfillmentContext {
10491 predicates : ObligationForest :: new ( ) ,
10592 relationships : FxHashMap :: default ( ) ,
106- register_region_obligations : true ,
10793 usable_in_snapshot : false ,
10894 }
10995 }
@@ -112,30 +98,18 @@ impl<'a, 'tcx> FulfillmentContext<'tcx> {
11298 FulfillmentContext {
11399 predicates : ObligationForest :: new ( ) ,
114100 relationships : FxHashMap :: default ( ) ,
115- register_region_obligations : true ,
116101 usable_in_snapshot : true ,
117102 }
118103 }
119104
120- pub fn new_ignoring_regions ( ) -> FulfillmentContext < ' tcx > {
121- FulfillmentContext {
122- predicates : ObligationForest :: new ( ) ,
123- relationships : FxHashMap :: default ( ) ,
124- register_region_obligations : false ,
125- usable_in_snapshot : false ,
126- }
127- }
128-
129105 /// Attempts to select obligations using `selcx`.
130106 fn select ( & mut self , selcx : & mut SelectionContext < ' a , ' tcx > ) -> Vec < FulfillmentError < ' tcx > > {
131107 let span = debug_span ! ( "select" , obligation_forest_size = ?self . predicates. len( ) ) ;
132108 let _enter = span. enter ( ) ;
133109
134110 // Process pending obligations.
135- let outcome: Outcome < _ , _ > = self . predicates . process_obligations ( & mut FulfillProcessor {
136- selcx,
137- register_region_obligations : self . register_region_obligations ,
138- } ) ;
111+ let outcome: Outcome < _ , _ > =
112+ self . predicates . process_obligations ( & mut FulfillProcessor { selcx } ) ;
139113
140114 // FIXME: if we kept the original cache key, we could mark projection
141115 // obligations as complete for the projection cache here.
@@ -239,7 +213,6 @@ impl<'tcx> TraitEngine<'tcx> for FulfillmentContext<'tcx> {
239213
240214struct FulfillProcessor < ' a , ' b , ' tcx > {
241215 selcx : & ' a mut SelectionContext < ' b , ' tcx > ,
242- register_region_obligations : bool ,
243216}
244217
245218fn mk_pending ( os : Vec < PredicateObligation < ' _ > > ) -> Vec < PendingPredicateObligation < ' _ > > {
@@ -385,19 +358,16 @@ impl<'a, 'b, 'tcx> ObligationProcessor for FulfillProcessor<'a, 'b, 'tcx> {
385358 }
386359
387360 ty:: PredicateKind :: RegionOutlives ( data) => {
388- match infcx. region_outlives_predicate ( & obligation. cause , Binder :: dummy ( data) ) {
389- Ok ( ( ) ) => ProcessResult :: Changed ( vec ! [ ] ) ,
390- Err ( _) => ProcessResult :: Error ( CodeSelectionError ( Unimplemented ) ) ,
361+ if infcx. considering_regions || data. has_placeholders ( ) {
362+ infcx. region_outlives_predicate ( & obligation. cause , Binder :: dummy ( data) ) ;
391363 }
364+
365+ ProcessResult :: Changed ( vec ! [ ] )
392366 }
393367
394368 ty:: PredicateKind :: TypeOutlives ( ty:: OutlivesPredicate ( t_a, r_b) ) => {
395- if self . register_region_obligations {
396- self . selcx . infcx ( ) . register_region_obligation_with_cause (
397- t_a,
398- r_b,
399- & obligation. cause ,
400- ) ;
369+ if infcx. considering_regions {
370+ infcx. register_region_obligation_with_cause ( t_a, r_b, & obligation. cause ) ;
401371 }
402372 ProcessResult :: Changed ( vec ! [ ] )
403373 }
0 commit comments