@@ -102,23 +102,15 @@ impl<'cx, 'gcx, 'tcx> VerifyBoundCx<'cx, 'gcx, 'tcx> {
102
102
self . declared_projection_bounds_from_trait ( projection_ty)
103
103
}
104
104
105
- pub fn projection_bound (
106
- & self ,
107
- projection_ty : ty:: ProjectionTy < ' tcx > ,
108
- ) -> VerifyBound < ' tcx > {
109
- debug ! (
110
- "projection_bound(projection_ty={:?})" ,
111
- projection_ty
112
- ) ;
105
+ pub fn projection_bound ( & self , projection_ty : ty:: ProjectionTy < ' tcx > ) -> VerifyBound < ' tcx > {
106
+ debug ! ( "projection_bound(projection_ty={:?})" , projection_ty) ;
113
107
114
108
// Search the env for where clauses like `P: 'a`.
115
109
let mut declared_bounds =
116
110
self . declared_generic_bounds_from_env ( GenericKind :: Projection ( projection_ty) ) ;
117
111
118
112
// Extend with bounds that we can find from the trait.
119
- declared_bounds. extend (
120
- self . projection_declared_bounds_from_trait ( projection_ty)
121
- ) ;
113
+ declared_bounds. extend ( self . projection_declared_bounds_from_trait ( projection_ty) ) ;
122
114
123
115
debug ! ( "projection_bound: declared_bounds = {:?}" , declared_bounds) ;
124
116
@@ -158,6 +150,14 @@ impl<'cx, 'gcx, 'tcx> VerifyBoundCx<'cx, 'gcx, 'tcx> {
158
150
fn declared_generic_bounds_from_env (
159
151
& self ,
160
152
generic : GenericKind < ' tcx > ,
153
+ ) -> Vec < ty:: Region < ' tcx > > {
154
+ let generic_ty = generic. to_ty ( self . tcx ) ;
155
+ self . declared_generic_bounds_from_env_with_compare_fn ( |ty| ty == generic_ty)
156
+ }
157
+
158
+ fn declared_generic_bounds_from_env_with_compare_fn (
159
+ & self ,
160
+ compare_ty : impl Fn ( Ty < ' tcx > ) -> bool ,
161
161
) -> Vec < ty:: Region < ' tcx > > {
162
162
let tcx = self . tcx ;
163
163
@@ -167,12 +167,8 @@ impl<'cx, 'gcx, 'tcx> VerifyBoundCx<'cx, 'gcx, 'tcx> {
167
167
// dubious for projections, but it will work for simple cases
168
168
// like `T` and `T::Item`. It may not work as well for things
169
169
// like `<T as Foo<'a>>::Item`.
170
- let generic_ty = generic. to_ty ( tcx) ;
171
170
let c_b = self . param_env . caller_bounds ;
172
- let mut param_bounds = self . collect_outlives_from_predicate_list (
173
- |ty| ty == generic_ty,
174
- c_b,
175
- ) ;
171
+ let mut param_bounds = self . collect_outlives_from_predicate_list ( & compare_ty, c_b) ;
176
172
177
173
// Next, collect regions we scraped from the well-formedness
178
174
// constraints in the fn signature. To do that, we walk the list
@@ -186,8 +182,11 @@ impl<'cx, 'gcx, 'tcx> VerifyBoundCx<'cx, 'gcx, 'tcx> {
186
182
// well-formed, then, A must be lower-generic by `'a`, but we
187
183
// don't know that this holds from first principles.
188
184
for & ( r, p) in self . region_bound_pairs {
189
- debug ! ( "generic={:?} p={:?}" , generic, p) ;
190
- if generic == p {
185
+ debug ! (
186
+ "declared_generic_bounds_from_env_with_compare_fn: region_bound_pair = {:?}" ,
187
+ ( r, p)
188
+ ) ;
189
+ if compare_ty ( p. to_ty ( tcx) ) {
191
190
param_bounds. push ( r) ;
192
191
}
193
192
}
0 commit comments