@@ -6,7 +6,7 @@ use rustc_data_structures::captures::Captures;
6
6
use rustc_data_structures:: sso:: SsoHashSet ;
7
7
use rustc_hir:: def_id:: DefId ;
8
8
use 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 } ;
10
10
11
11
use smallvec:: smallvec;
12
12
@@ -114,16 +114,6 @@ impl<'cx, 'tcx> VerifyBoundCx<'cx, 'tcx> {
114
114
self . declared_generic_bounds_from_env_for_erased_ty ( erased_projection_ty)
115
115
}
116
116
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
-
127
117
#[ instrument( level = "debug" , skip( self , visited) ) ]
128
118
fn projection_bound (
129
119
& self ,
@@ -151,7 +141,7 @@ impl<'cx, 'tcx> VerifyBoundCx<'cx, 'tcx> {
151
141
152
142
// Extend with bounds that we can find from the trait.
153
143
let trait_bounds = self
154
- . projection_declared_bounds_from_trait ( projection_ty)
144
+ . bounds ( projection_ty. item_def_id , projection_ty . substs )
155
145
. map ( |r| VerifyBound :: OutlivedBy ( r) ) ;
156
146
157
147
// see the extensive comment in projection_must_outlive
@@ -294,15 +284,15 @@ impl<'cx, 'tcx> VerifyBoundCx<'cx, 'tcx> {
294
284
///
295
285
/// then this function would return `'x`. This is subject to the
296
286
/// 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 (
299
290
& self ,
300
- projection_ty : ty:: ProjectionTy < ' tcx > ,
291
+ def_id : DefId ,
292
+ substs : SubstsRef < ' tcx > ,
301
293
) -> impl Iterator < Item = ty:: Region < ' tcx > > + ' cx + Captures < ' tcx > {
302
- debug ! ( "projection_bounds(projection_ty={:?})" , projection_ty) ;
303
294
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) )
306
296
}
307
297
308
298
/// Given the `DefId` of an associated item, returns any region
@@ -335,12 +325,10 @@ impl<'cx, 'tcx> VerifyBoundCx<'cx, 'tcx> {
335
325
///
336
326
/// This is for simplicity, and because we are not really smart
337
327
/// 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 > > {
342
329
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) ;
344
332
bounds
345
333
. into_iter ( )
346
334
. filter_map ( |p| p. to_opt_type_outlives ( ) )
0 commit comments