@@ -2,7 +2,6 @@ use crate::infer::outlives::components::{compute_components_recursive, Component
22use crate :: infer:: outlives:: env:: RegionBoundPairs ;
33use crate :: infer:: region_constraints:: VerifyIfEq ;
44use crate :: infer:: { GenericKind , VerifyBound } ;
5- use rustc_data_structures:: captures:: Captures ;
65use rustc_data_structures:: sso:: SsoHashSet ;
76use rustc_hir:: def_id:: DefId ;
87use rustc_middle:: ty:: GenericArg ;
@@ -128,7 +127,8 @@ impl<'cx, 'tcx> VerifyBoundCx<'cx, 'tcx> {
128127 }
129128 } ) ;
130129 // Extend with bounds that we can find from the trait.
131- let trait_bounds = self . bounds ( def_id, substs) . map ( |r| VerifyBound :: OutlivedBy ( r) ) ;
130+ let trait_bounds =
131+ self . declared_region_bounds ( def_id, substs) . map ( |r| VerifyBound :: OutlivedBy ( r) ) ;
132132
133133 // see the extensive comment in projection_must_outlive
134134 let recursive_bound = {
@@ -279,30 +279,6 @@ impl<'cx, 'tcx> VerifyBoundCx<'cx, 'tcx> {
279279 /// }
280280 /// ```
281281 ///
282- /// then this function would return `'x`. This is subject to the
283- /// limitations around higher-ranked bounds described in
284- /// `declared_region_bounds`.
285- #[ instrument( level = "debug" , skip( self ) ) ]
286- pub fn bounds (
287- & self ,
288- def_id : DefId ,
289- substs : SubstsRef < ' tcx > ,
290- ) -> impl Iterator < Item = ty:: Region < ' tcx > > + ' cx + Captures < ' tcx > {
291- let tcx = self . tcx ;
292- self . declared_region_bounds ( def_id) . map ( move |r| EarlyBinder ( r) . subst ( tcx, substs) )
293- }
294-
295- /// Given the `DefId` of an associated item, returns any region
296- /// bounds attached to that associated item from the trait definition.
297- ///
298- /// For example:
299- ///
300- /// ```rust
301- /// trait Foo<'a> {
302- /// type Bar: 'a;
303- /// }
304- /// ```
305- ///
306282 /// If we were given the `DefId` of `Foo::Bar`, we would return
307283 /// `'a`. You could then apply the substitutions from the
308284 /// projection to convert this into your namespace. This also
@@ -322,7 +298,11 @@ impl<'cx, 'tcx> VerifyBoundCx<'cx, 'tcx> {
322298 ///
323299 /// This is for simplicity, and because we are not really smart
324300 /// enough to cope with such bounds anywhere.
325- fn declared_region_bounds ( & self , def_id : DefId ) -> impl Iterator < Item = ty:: Region < ' tcx > > {
301+ pub fn declared_region_bounds (
302+ & self ,
303+ def_id : DefId ,
304+ substs : SubstsRef < ' tcx > ,
305+ ) -> impl Iterator < Item = ty:: Region < ' tcx > > {
326306 let tcx = self . tcx ;
327307 let bounds = tcx. item_bounds ( def_id) ;
328308 trace ! ( "{:#?}" , bounds) ;
@@ -331,6 +311,7 @@ impl<'cx, 'tcx> VerifyBoundCx<'cx, 'tcx> {
331311 . filter_map ( |p| p. to_opt_type_outlives ( ) )
332312 . filter_map ( |p| p. no_bound_vars ( ) )
333313 . map ( |b| b. 1 )
314+ . map ( move |r| EarlyBinder ( r) . subst ( tcx, substs) )
334315 }
335316
336317 /// Searches through a predicate list for a predicate `T: 'a`.
0 commit comments