@@ -91,14 +91,14 @@ impl<'cx, 'gcx, 'tcx> VerifyBoundCx<'cx, 'gcx, 'tcx> {
9191 ) -> Vec < ty:: Region < ' tcx > > {
9292 let projection_ty = GenericKind :: Projection ( projection_ty) . to_ty ( self . tcx ) ;
9393 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 {
9696 let erased_ty = self . tcx . erase_regions ( & ty) ;
9797 erased_ty == erased_projection_ty
9898 } else {
9999 false
100- } ,
101- )
100+ }
101+ } )
102102 }
103103
104104 /// Searches the where clauses in scope for regions that
@@ -177,7 +177,7 @@ impl<'cx, 'gcx, 'tcx> VerifyBoundCx<'cx, 'gcx, 'tcx> {
177177 // like `T` and `T::Item`. It may not work as well for things
178178 // like `<T as Foo<'a>>::Item`.
179179 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) ;
181181
182182 // Next, collect regions we scraped from the well-formedness
183183 // constraints in the fn signature. To do that, we walk the list
@@ -190,17 +190,19 @@ impl<'cx, 'gcx, 'tcx> VerifyBoundCx<'cx, 'gcx, 'tcx> {
190190 // The problem is that the type of `x` is `&'a A`. To be
191191 // well-formed, then, A must be lower-generic by `'a`, but we
192192 // 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) | {
194194 debug ! (
195195 "declared_generic_bounds_from_env_with_compare_fn: region_bound_pair = {:?}" ,
196196 ( r, p)
197197 ) ;
198198 if compare_ty ( p. to_ty ( tcx) ) {
199- param_bounds. push ( r) ;
199+ Some ( r)
200+ } else {
201+ None
200202 }
201- }
203+ } ) ;
202204
203- param_bounds
205+ param_bounds. chain ( from_region_bound_pairs ) . collect ( )
204206 }
205207
206208 /// Given a projection like `<T as Foo<'x>>::Bar`, returns any bounds
@@ -268,9 +270,9 @@ impl<'cx, 'gcx, 'tcx> VerifyBoundCx<'cx, 'gcx, 'tcx> {
268270 let identity_substs = Substs :: identity_for_item ( tcx, assoc_item_def_id) ;
269271 let identity_proj = tcx. mk_projection ( assoc_item_def_id, identity_substs) ;
270272 self . collect_outlives_from_predicate_list (
271- |ty| ty == identity_proj,
273+ move |ty| ty == identity_proj,
272274 traits:: elaborate_predicates ( tcx, trait_predicates. predicates ) ,
273- )
275+ ) . collect ( )
274276 }
275277
276278 /// Searches through a predicate list for a predicate `T: 'a`.
@@ -283,13 +285,12 @@ impl<'cx, 'gcx, 'tcx> VerifyBoundCx<'cx, 'gcx, 'tcx> {
283285 & self ,
284286 compare_ty : impl Fn ( Ty < ' tcx > ) -> bool ,
285287 predicates : impl IntoIterator < Item = impl AsRef < ty:: Predicate < ' tcx > > > ,
286- ) -> Vec < ty:: Region < ' tcx > > {
288+ ) -> impl Iterator < Item = ty:: Region < ' tcx > > {
287289 predicates
288290 . into_iter ( )
289291 . filter_map ( |p| p. as_ref ( ) . to_opt_type_outlives ( ) )
290292 . filter_map ( |p| p. no_late_bound_regions ( ) )
291- . filter ( |p| compare_ty ( p. 0 ) )
293+ . filter ( move |p| compare_ty ( p. 0 ) )
292294 . map ( |p| p. 1 )
293- . collect ( )
294295 }
295296}
0 commit comments