@@ -192,7 +192,7 @@ impl<'cx, 'tcx> VerifyBoundCx<'cx, 'tcx> {
192192 /// Obviously these must be approximate -- they are in fact both *over* and
193193 /// and *under* approximated:
194194 ///
195- /// * Over-approximated because we erase regions, so
195+ /// * Over-approximated because we don't consider equality of regions.
196196 /// * Under-approximated because we look for syntactic equality and so for complex types
197197 /// like `<T as Foo<fn(&u32, &u32)>>::Item` or whatever we may fail to figure out
198198 /// all the subtleties.
@@ -205,13 +205,14 @@ impl<'cx, 'tcx> VerifyBoundCx<'cx, 'tcx> {
205205 erased_ty : Ty < ' tcx > ,
206206 ) -> Vec < ty:: PolyTypeOutlivesPredicate < ' tcx > > {
207207 let tcx = self . tcx ;
208+ let mut bounds = vec ! [ ] ;
208209
209210 // To start, collect bounds from user environment. Note that
210211 // parameter environments are already elaborated, so we don't
211212 // have to worry about that.
212- let param_bounds = self . caller_bounds . iter ( ) . copied ( ) . filter ( move |outlives_predicate| {
213+ bounds . extend ( self . caller_bounds . iter ( ) . copied ( ) . filter ( move |outlives_predicate| {
213214 super :: test_type_match:: can_match_erased_ty ( tcx, * outlives_predicate, erased_ty)
214- } ) ;
215+ } ) ) ;
215216
216217 // Next, collect regions we scraped from the well-formedness
217218 // constraints in the fn signature. To do that, we walk the list
@@ -224,37 +225,27 @@ impl<'cx, 'tcx> VerifyBoundCx<'cx, 'tcx> {
224225 // The problem is that the type of `x` is `&'a A`. To be
225226 // well-formed, then, A must outlive `'a`, but we don't know that
226227 // this holds from first principles.
227- let from_region_bound_pairs =
228- self . region_bound_pairs . iter ( ) . filter_map ( |& OutlivesPredicate ( p, r) | {
229- debug ! (
230- "declared_generic_bounds_from_env_for_erased_ty: region_bound_pair = {:?}" ,
231- ( r, p)
232- ) ;
233- // Fast path for the common case.
234- match ( & p, erased_ty. kind ( ) ) {
235- // In outlive routines, all types are expected to be fully normalized.
236- // And therefore we can safely use structural equality for alias types.
237- ( GenericKind :: Param ( p1) , ty:: Param ( p2) ) if p1 == p2 => { }
238- ( GenericKind :: Placeholder ( p1) , ty:: Placeholder ( p2) ) if p1 == p2 => { }
239- ( GenericKind :: Alias ( a1) , ty:: Alias ( _, a2) ) if a1. def_id == a2. def_id => { }
240- _ => return None ,
241- }
228+ bounds. extend ( self . region_bound_pairs . iter ( ) . filter_map ( |& OutlivesPredicate ( p, r) | {
229+ debug ! (
230+ "declared_generic_bounds_from_env_for_erased_ty: region_bound_pair = {:?}" ,
231+ ( r, p)
232+ ) ;
233+ // Fast path for the common case.
234+ match ( & p, erased_ty. kind ( ) ) {
235+ // In outlive routines, all types are expected to be fully normalized.
236+ // And therefore we can safely use structural equality for alias types.
237+ ( GenericKind :: Param ( p1) , ty:: Param ( p2) ) if p1 == p2 => { }
238+ ( GenericKind :: Placeholder ( p1) , ty:: Placeholder ( p2) ) if p1 == p2 => { }
239+ ( GenericKind :: Alias ( a1) , ty:: Alias ( _, a2) ) if a1. def_id == a2. def_id => { }
240+ _ => return None ,
241+ }
242242
243- let p_ty = p. to_ty ( tcx) ;
244- let erased_p_ty = self . tcx . erase_regions ( p_ty) ;
245- ( erased_p_ty == erased_ty)
246- . then_some ( ty:: Binder :: dummy ( ty:: OutlivesPredicate ( p_ty, r) ) )
247- } ) ;
243+ let p_ty = p. to_ty ( tcx) ;
244+ let erased_p_ty = self . tcx . erase_regions ( p_ty) ;
245+ ( erased_p_ty == erased_ty) . then_some ( ty:: Binder :: dummy ( ty:: OutlivesPredicate ( p_ty, r) ) )
246+ } ) ) ;
248247
249- param_bounds
250- . chain ( from_region_bound_pairs)
251- . inspect ( |bound| {
252- debug ! (
253- "declared_generic_bounds_from_env_for_erased_ty: result predicate = {:?}" ,
254- bound
255- )
256- } )
257- . collect ( )
248+ bounds
258249 }
259250
260251 /// Given a projection like `<T as Foo<'x>>::Bar`, returns any bounds
0 commit comments