@@ -2287,17 +2287,52 @@ impl<'o, 'gcx: 'tcx, 'tcx> dyn AstConv<'gcx, 'tcx> + 'o {
2287
2287
}
2288
2288
}
2289
2289
2290
- // A helper struct for conveniently grouping a set of bounds which we pass to
2291
- // and return from functions in multiple places.
2290
+ /// Collects together a list of bounds that are applied to some type,
2291
+ /// after they've been converted into `ty` form (from the HIR
2292
+ /// representations). These lists of bounds occur in many places in
2293
+ /// Rust's syntax:
2294
+ ///
2295
+ /// ```
2296
+ /// trait Foo: Bar + Baz { }
2297
+ /// ^^^^^^^^^ supertrait list bounding the `Self` type parameter
2298
+ ///
2299
+ /// fn foo<T: Bar + Baz>() { }
2300
+ /// ^^^^^^^^^ bounding the type parameter `T`
2301
+ ///
2302
+ /// impl dyn Bar + Baz
2303
+ /// ^^^^^^^^^ bounding the forgotten dynamic type
2304
+ /// ```
2305
+ ///
2306
+ /// Our representation is a bit mixed here -- in some cases, we
2307
+ /// include the self type (e.g., `trait_bounds`) but in others we do
2292
2308
#[ derive( Default , PartialEq , Eq , Clone , Debug ) ]
2293
2309
pub struct Bounds < ' tcx > {
2310
+ /// A list of region bounds on the (implicit) self type. So if you
2311
+ /// had `T: 'a + 'b` this might would be a list `['a, 'b]` (but
2312
+ /// the `T` is not explicitly included).
2294
2313
pub region_bounds : Vec < ( ty:: Region < ' tcx > , Span ) > ,
2314
+
2315
+ /// A list of trait bounds. So if you had `T: Debug` this would be
2316
+ /// `T: Debug`. Note that the self-type is explicit here.
2295
2317
pub trait_bounds : Vec < ( ty:: PolyTraitRef < ' tcx > , Span ) > ,
2318
+
2319
+ /// A list of projection equality bounds. So if you had `T:
2320
+ /// Iterator<Item = u32>` this would include `<T as
2321
+ /// Iterator>::Item => u32`. Note that the self-type is explicit
2322
+ /// here.
2296
2323
pub projection_bounds : Vec < ( ty:: PolyProjectionPredicate < ' tcx > , Span ) > ,
2324
+
2325
+ /// `Some` if there is *no* `?Sized` predicate. The `span`
2326
+ /// is the location in the source of the `T` declaration which can
2327
+ /// be cited as the source of the `T: Sized` requirement.
2297
2328
pub implicitly_sized : Option < Span > ,
2298
2329
}
2299
2330
2300
2331
impl < ' a , ' gcx , ' tcx > Bounds < ' tcx > {
2332
+ /// Converts a bounds list into a flat set of predicates (like
2333
+ /// where-clauses). Because some of our bounds listings (e.g.,
2334
+ /// regions) don't include the self-type, you must supply the
2335
+ /// self-type here (the `param_ty` parameter).
2301
2336
pub fn predicates ( & self , tcx : TyCtxt < ' a , ' gcx , ' tcx > , param_ty : Ty < ' tcx > )
2302
2337
-> Vec < ( ty:: Predicate < ' tcx > , Span ) >
2303
2338
{
0 commit comments