1
1
use crate :: infer:: free_regions:: FreeRegionMap ;
2
- use crate :: infer:: { GenericKind , InferCtxt } ;
2
+ use crate :: infer:: GenericKind ;
3
3
use crate :: traits:: query:: OutlivesBound ;
4
4
use rustc_data_structures:: fx:: FxIndexSet ;
5
5
use rustc_data_structures:: transitive_relation:: TransitiveRelationBuilder ;
6
- use rustc_middle:: ty:: { self , ReEarlyBound , ReFree , ReVar , Region } ;
6
+ use rustc_middle:: ty:: { self , Region } ;
7
7
8
8
use super :: explicit_outlives_bounds;
9
9
@@ -75,7 +75,7 @@ impl<'tcx> OutlivesEnvironment<'tcx> {
75
75
region_bound_pairs : Default :: default ( ) ,
76
76
} ;
77
77
78
- builder. add_outlives_bounds ( None , explicit_outlives_bounds ( param_env) ) ;
78
+ builder. add_outlives_bounds ( explicit_outlives_bounds ( param_env) ) ;
79
79
80
80
builder
81
81
}
@@ -89,11 +89,10 @@ impl<'tcx> OutlivesEnvironment<'tcx> {
89
89
/// Create a new `OutlivesEnvironment` with extra outlives bounds.
90
90
pub fn with_bounds (
91
91
param_env : ty:: ParamEnv < ' tcx > ,
92
- infcx : Option < & InferCtxt < ' tcx > > ,
93
92
extra_bounds : impl IntoIterator < Item = OutlivesBound < ' tcx > > ,
94
93
) -> Self {
95
94
let mut builder = Self :: builder ( param_env) ;
96
- builder. add_outlives_bounds ( infcx , extra_bounds) ;
95
+ builder. add_outlives_bounds ( extra_bounds) ;
97
96
builder. build ( )
98
97
}
99
98
@@ -120,12 +119,7 @@ impl<'tcx> OutlivesEnvironmentBuilder<'tcx> {
120
119
}
121
120
122
121
/// Processes outlives bounds that are known to hold, whether from implied or other sources.
123
- ///
124
- /// The `infcx` parameter is optional; if the implied bounds may
125
- /// contain inference variables, it must be supplied, in which
126
- /// case we will register "givens" on the inference context. (See
127
- /// `RegionConstraintData`.)
128
- fn add_outlives_bounds < I > ( & mut self , infcx : Option < & InferCtxt < ' tcx > > , outlives_bounds : I )
122
+ fn add_outlives_bounds < I > ( & mut self , outlives_bounds : I )
129
123
where
130
124
I : IntoIterator < Item = OutlivesBound < ' tcx > > ,
131
125
{
@@ -142,27 +136,17 @@ impl<'tcx> OutlivesEnvironmentBuilder<'tcx> {
142
136
self . region_bound_pairs
143
137
. insert ( ty:: OutlivesPredicate ( GenericKind :: Alias ( alias_b) , r_a) ) ;
144
138
}
145
- OutlivesBound :: RegionSubRegion ( r_a, r_b) => {
146
- if let ( ReEarlyBound ( _) | ReFree ( _) , ReVar ( vid_b) ) = ( r_a. kind ( ) , r_b. kind ( ) ) {
147
- infcx
148
- . expect ( "no infcx provided but region vars found" )
149
- . add_given ( r_a, vid_b) ;
150
- } else {
151
- // In principle, we could record (and take
152
- // advantage of) every relationship here, but
153
- // we are also free not to -- it simply means
154
- // strictly less that we can successfully type
155
- // check. Right now we only look for things
156
- // relationships between free regions. (It may
157
- // also be that we should revise our inference
158
- // system to be more general and to make use
159
- // of *every* relationship that arises here,
160
- // but presently we do not.)
161
- if r_a. is_free_or_static ( ) && r_b. is_free ( ) {
162
- self . region_relation . add ( r_a, r_b)
163
- }
164
- }
165
- }
139
+ OutlivesBound :: RegionSubRegion ( r_a, r_b) => match ( * r_a, * r_b) {
140
+ (
141
+ ty:: ReStatic | ty:: ReEarlyBound ( _) | ty:: ReFree ( _) ,
142
+ ty:: ReStatic | ty:: ReEarlyBound ( _) | ty:: ReFree ( _) ,
143
+ ) => self . region_relation . add ( r_a, r_b) ,
144
+ ( ty:: ReError ( _) , _) | ( _, ty:: ReError ( _) ) => { }
145
+ // FIXME(#109628): We shouldn't have existential variables in implied bounds.
146
+ // Panic here once the linked issue is resolved!
147
+ ( ty:: ReVar ( _) , _) | ( _, ty:: ReVar ( _) ) => { }
148
+ _ => bug ! ( "add_outlives_bounds: unexpected regions: ({r_a:?}, {r_b:?})" ) ,
149
+ } ,
166
150
}
167
151
}
168
152
}
0 commit comments