@@ -2,7 +2,6 @@ use crate::infer::outlives::components::{compute_components_recursive, Component
2
2
use crate :: infer:: outlives:: env:: RegionBoundPairs ;
3
3
use crate :: infer:: region_constraints:: VerifyIfEq ;
4
4
use crate :: infer:: { GenericKind , VerifyBound } ;
5
- use rustc_data_structures:: captures:: Captures ;
6
5
use rustc_data_structures:: sso:: SsoHashSet ;
7
6
use rustc_hir:: def_id:: DefId ;
8
7
use rustc_middle:: ty:: GenericArg ;
@@ -128,7 +127,8 @@ impl<'cx, 'tcx> VerifyBoundCx<'cx, 'tcx> {
128
127
}
129
128
} ) ;
130
129
// 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) ) ;
132
132
133
133
// see the extensive comment in projection_must_outlive
134
134
let recursive_bound = {
@@ -279,30 +279,6 @@ impl<'cx, 'tcx> VerifyBoundCx<'cx, 'tcx> {
279
279
/// }
280
280
/// ```
281
281
///
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
- ///
306
282
/// If we were given the `DefId` of `Foo::Bar`, we would return
307
283
/// `'a`. You could then apply the substitutions from the
308
284
/// projection to convert this into your namespace. This also
@@ -322,7 +298,11 @@ impl<'cx, 'tcx> VerifyBoundCx<'cx, 'tcx> {
322
298
///
323
299
/// This is for simplicity, and because we are not really smart
324
300
/// 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 > > {
326
306
let tcx = self . tcx ;
327
307
let bounds = tcx. item_bounds ( def_id) ;
328
308
trace ! ( "{:#?}" , bounds) ;
@@ -331,6 +311,7 @@ impl<'cx, 'tcx> VerifyBoundCx<'cx, 'tcx> {
331
311
. filter_map ( |p| p. to_opt_type_outlives ( ) )
332
312
. filter_map ( |p| p. no_bound_vars ( ) )
333
313
. map ( |b| b. 1 )
314
+ . map ( move |r| EarlyBinder ( r) . subst ( tcx, substs) )
334
315
}
335
316
336
317
/// Searches through a predicate list for a predicate `T: 'a`.
0 commit comments