@@ -6,7 +6,7 @@ use rustc_data_structures::captures::Captures;
66use rustc_data_structures:: sso:: SsoHashSet ;
77use rustc_hir:: def_id:: DefId ;
88use rustc_middle:: ty:: GenericArg ;
9- use rustc_middle:: ty:: { self , EarlyBinder , OutlivesPredicate , Ty , TyCtxt } ;
9+ use rustc_middle:: ty:: { self , EarlyBinder , OutlivesPredicate , SubstsRef , Ty , TyCtxt } ;
1010
1111use smallvec:: smallvec;
1212
@@ -114,16 +114,6 @@ impl<'cx, 'tcx> VerifyBoundCx<'cx, 'tcx> {
114114 self . declared_generic_bounds_from_env_for_erased_ty ( erased_projection_ty)
115115 }
116116
117- /// Searches the where-clauses in scope for regions that
118- /// `projection_ty` is known to outlive. Currently requires an
119- /// exact match.
120- pub fn projection_declared_bounds_from_trait (
121- & self ,
122- projection_ty : ty:: ProjectionTy < ' tcx > ,
123- ) -> impl Iterator < Item = ty:: Region < ' tcx > > + ' cx + Captures < ' tcx > {
124- self . declared_projection_bounds_from_trait ( projection_ty)
125- }
126-
127117 #[ instrument( level = "debug" , skip( self , visited) ) ]
128118 fn projection_bound (
129119 & self ,
@@ -151,7 +141,7 @@ impl<'cx, 'tcx> VerifyBoundCx<'cx, 'tcx> {
151141
152142 // Extend with bounds that we can find from the trait.
153143 let trait_bounds = self
154- . projection_declared_bounds_from_trait ( projection_ty)
144+ . bounds ( projection_ty. item_def_id , projection_ty . substs )
155145 . map ( |r| VerifyBound :: OutlivedBy ( r) ) ;
156146
157147 // see the extensive comment in projection_must_outlive
@@ -294,15 +284,15 @@ impl<'cx, 'tcx> VerifyBoundCx<'cx, 'tcx> {
294284 ///
295285 /// then this function would return `'x`. This is subject to the
296286 /// limitations around higher-ranked bounds described in
297- /// `region_bounds_declared_on_associated_item`.
298- fn declared_projection_bounds_from_trait (
287+ /// `declared_region_bounds`.
288+ #[ instrument( level = "debug" , skip( self ) ) ]
289+ pub fn bounds (
299290 & self ,
300- projection_ty : ty:: ProjectionTy < ' tcx > ,
291+ def_id : DefId ,
292+ substs : SubstsRef < ' tcx > ,
301293 ) -> impl Iterator < Item = ty:: Region < ' tcx > > + ' cx + Captures < ' tcx > {
302- debug ! ( "projection_bounds(projection_ty={:?})" , projection_ty) ;
303294 let tcx = self . tcx ;
304- self . region_bounds_declared_on_associated_item ( projection_ty. item_def_id )
305- . map ( move |r| EarlyBinder ( r) . subst ( tcx, projection_ty. substs ) )
295+ self . declared_region_bounds ( def_id) . map ( move |r| EarlyBinder ( r) . subst ( tcx, substs) )
306296 }
307297
308298 /// Given the `DefId` of an associated item, returns any region
@@ -335,12 +325,10 @@ impl<'cx, 'tcx> VerifyBoundCx<'cx, 'tcx> {
335325 ///
336326 /// This is for simplicity, and because we are not really smart
337327 /// enough to cope with such bounds anywhere.
338- fn region_bounds_declared_on_associated_item (
339- & self ,
340- assoc_item_def_id : DefId ,
341- ) -> impl Iterator < Item = ty:: Region < ' tcx > > {
328+ fn declared_region_bounds ( & self , def_id : DefId ) -> impl Iterator < Item = ty:: Region < ' tcx > > {
342329 let tcx = self . tcx ;
343- let bounds = tcx. item_bounds ( assoc_item_def_id) ;
330+ let bounds = tcx. item_bounds ( def_id) ;
331+ trace ! ( "{:#?}" , bounds) ;
344332 bounds
345333 . into_iter ( )
346334 . filter_map ( |p| p. to_opt_type_outlives ( ) )
0 commit comments