@@ -91,14 +91,14 @@ impl<'cx, 'gcx, 'tcx> VerifyBoundCx<'cx, 'gcx, 'tcx> {
91
91
) -> Vec < ty:: Region < ' tcx > > {
92
92
let projection_ty = GenericKind :: Projection ( projection_ty) . to_ty ( self . tcx ) ;
93
93
let erased_projection_ty = self . tcx . erase_regions ( & projection_ty) ;
94
- self . declared_generic_bounds_from_env_with_compare_fn (
95
- |ty| if let ty:: Projection ( ..) = ty. sty {
94
+ self . declared_generic_bounds_from_env_with_compare_fn ( |ty| {
95
+ if let ty:: Projection ( ..) = ty. sty {
96
96
let erased_ty = self . tcx . erase_regions ( & ty) ;
97
97
erased_ty == erased_projection_ty
98
98
} else {
99
99
false
100
- } ,
101
- )
100
+ }
101
+ } )
102
102
}
103
103
104
104
/// Searches the where clauses in scope for regions that
@@ -177,7 +177,7 @@ impl<'cx, 'gcx, 'tcx> VerifyBoundCx<'cx, 'gcx, 'tcx> {
177
177
// like `T` and `T::Item`. It may not work as well for things
178
178
// like `<T as Foo<'a>>::Item`.
179
179
let c_b = self . param_env . caller_bounds ;
180
- let mut param_bounds = self . collect_outlives_from_predicate_list ( & compare_ty, c_b) ;
180
+ let param_bounds = self . collect_outlives_from_predicate_list ( & compare_ty, c_b) ;
181
181
182
182
// Next, collect regions we scraped from the well-formedness
183
183
// constraints in the fn signature. To do that, we walk the list
@@ -190,17 +190,19 @@ impl<'cx, 'gcx, 'tcx> VerifyBoundCx<'cx, 'gcx, 'tcx> {
190
190
// The problem is that the type of `x` is `&'a A`. To be
191
191
// well-formed, then, A must be lower-generic by `'a`, but we
192
192
// don't know that this holds from first principles.
193
- for & ( r, p) in self . region_bound_pairs {
193
+ let from_region_bound_pairs = self . region_bound_pairs . iter ( ) . filter_map ( | & ( r, p) | {
194
194
debug ! (
195
195
"declared_generic_bounds_from_env_with_compare_fn: region_bound_pair = {:?}" ,
196
196
( r, p)
197
197
) ;
198
198
if compare_ty ( p. to_ty ( tcx) ) {
199
- param_bounds. push ( r) ;
199
+ Some ( r)
200
+ } else {
201
+ None
200
202
}
201
- }
203
+ } ) ;
202
204
203
- param_bounds
205
+ param_bounds. chain ( from_region_bound_pairs ) . collect ( )
204
206
}
205
207
206
208
/// Given a projection like `<T as Foo<'x>>::Bar`, returns any bounds
@@ -268,9 +270,9 @@ impl<'cx, 'gcx, 'tcx> VerifyBoundCx<'cx, 'gcx, 'tcx> {
268
270
let identity_substs = Substs :: identity_for_item ( tcx, assoc_item_def_id) ;
269
271
let identity_proj = tcx. mk_projection ( assoc_item_def_id, identity_substs) ;
270
272
self . collect_outlives_from_predicate_list (
271
- |ty| ty == identity_proj,
273
+ move |ty| ty == identity_proj,
272
274
traits:: elaborate_predicates ( tcx, trait_predicates. predicates ) ,
273
- )
275
+ ) . collect ( )
274
276
}
275
277
276
278
/// Searches through a predicate list for a predicate `T: 'a`.
@@ -283,13 +285,12 @@ impl<'cx, 'gcx, 'tcx> VerifyBoundCx<'cx, 'gcx, 'tcx> {
283
285
& self ,
284
286
compare_ty : impl Fn ( Ty < ' tcx > ) -> bool ,
285
287
predicates : impl IntoIterator < Item = impl AsRef < ty:: Predicate < ' tcx > > > ,
286
- ) -> Vec < ty:: Region < ' tcx > > {
288
+ ) -> impl Iterator < Item = ty:: Region < ' tcx > > {
287
289
predicates
288
290
. into_iter ( )
289
291
. filter_map ( |p| p. as_ref ( ) . to_opt_type_outlives ( ) )
290
292
. filter_map ( |p| p. no_late_bound_regions ( ) )
291
- . filter ( |p| compare_ty ( p. 0 ) )
293
+ . filter ( move |p| compare_ty ( p. 0 ) )
292
294
. map ( |p| p. 1 )
293
- . collect ( )
294
295
}
295
296
}
0 commit comments