@@ -258,9 +258,28 @@ struct AnonTypeDecl<'tcx> {
258
258
/// lifetime parameter on `foo`.)
259
259
concrete_ty : Ty < ' tcx > ,
260
260
261
- /// A list of all required region bounds on the impl Trait type,
262
- /// e.g. `'a` and `'b` in `fn foo<'a, 'b, 'c>() -> impl Trait<'c> + 'a + 'b`.
263
- required_region_bounds : Vec < ty:: Region < ' tcx > > ,
261
+ /// True if the `impl Trait` bounds include region bounds.
262
+ /// For example, this would be true for:
263
+ ///
264
+ /// fn foo<'a, 'b, 'c>() -> impl Trait<'c> + 'a + 'b
265
+ ///
266
+ /// but false for:
267
+ ///
268
+ /// fn foo<'c>() -> impl Trait<'c>
269
+ ///
270
+ /// unless `Trait` was declared like:
271
+ ///
272
+ /// trait Trait<'c>: 'c
273
+ ///
274
+ /// in which case it would be true.
275
+ ///
276
+ /// This is used during regionck to decide whether we need to
277
+ /// impose any additional constraints to ensure that region
278
+ /// variables in `concrete_ty` wind up being constrained to
279
+ /// something from `substs` (or, at minimum, things that outlive
280
+ /// the fn body). (Ultimately, writeback is responsible for this
281
+ /// check.)
282
+ has_required_region_bounds : bool ,
264
283
}
265
284
266
285
impl < ' a , ' gcx , ' tcx > Deref for Inherited < ' a , ' gcx , ' tcx > {
@@ -1941,7 +1960,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
1941
1960
self . anon_types . borrow_mut ( ) . insert ( def_id, AnonTypeDecl {
1942
1961
substs,
1943
1962
concrete_ty : ty_var,
1944
- required_region_bounds,
1963
+ has_required_region_bounds : ! required_region_bounds. is_empty ( ) ,
1945
1964
} ) ;
1946
1965
debug ! ( "instantiate_anon_types: ty_var={:?}" , ty_var) ;
1947
1966
0 commit comments