@@ -456,6 +456,21 @@ impl<'cx, 'gcx, 'tcx> UniversalRegionsBuilder<'cx, 'gcx, 'tcx> {
456
456
}
457
457
}
458
458
459
+ /// Returns the "defining type" of the current MIR:
460
+ ///
461
+ /// - for functions, this is the `TyFnDef`;
462
+ /// - for closures, this is the `TyClosure`;
463
+ /// - for generators, this is the `TyGenerator`;
464
+ /// - for constants, this is the type of value that gets produced.
465
+ /// - FIXME. Constants are handled somewhat inelegantly; this gets
466
+ /// patched in a later PR that has already landed on nll-master.
467
+ ///
468
+ /// The key feature of the "defining type" is that it contains the
469
+ /// information needed to derive all the universal regions that
470
+ /// are in scope as well as the types of the inputs/output from
471
+ /// the MIR. In general, early-bound universal regions appear free
472
+ /// in the defining type and late-bound regions appear bound in
473
+ /// the signature.
459
474
fn defining_ty ( & self ) -> ty:: Ty < ' tcx > {
460
475
let tcx = self . infcx . tcx ;
461
476
let closure_base_def_id = tcx. closure_base_def_id ( self . mir_def_id ) ;
@@ -471,6 +486,10 @@ impl<'cx, 'gcx, 'tcx> UniversalRegionsBuilder<'cx, 'gcx, 'tcx> {
471
486
. replace_free_regions_with_nll_infer_vars ( FR , & defining_ty)
472
487
}
473
488
489
+ /// Builds a hashmap that maps from the universal regions that are
490
+ /// in scope (as a `ty::Region<'tcx>`) to their indices (as a
491
+ /// `RegionVid`). The map returned by this function contains only
492
+ /// the early-bound regions.
474
493
fn compute_indices (
475
494
& self ,
476
495
fr_static : RegionVid ,
@@ -490,6 +509,7 @@ impl<'cx, 'gcx, 'tcx> UniversalRegionsBuilder<'cx, 'gcx, 'tcx> {
490
509
// that correspond to early-bound regions declared on
491
510
// the `closure_base_def_id`.
492
511
assert ! ( substs. substs. len( ) >= identity_substs. len( ) ) ;
512
+ assert_eq ! ( substs. substs. regions( ) . count( ) , identity_substs. regions( ) . count( ) ) ;
493
513
substs. substs
494
514
}
495
515
ty:: TyFnDef ( _, substs) => substs,
0 commit comments