comments for defining_ty
and compute_indices
Plus an extra assertion.
This commit is contained in:
parent
75ac071cd6
commit
abd6d0d76e
1 changed files with 20 additions and 0 deletions
|
@ -456,6 +456,21 @@ impl<'cx, 'gcx, 'tcx> UniversalRegionsBuilder<'cx, 'gcx, 'tcx> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Returns the "defining type" of the current MIR:
|
||||||
|
///
|
||||||
|
/// - for functions, this is the `TyFnDef`;
|
||||||
|
/// - for closures, this is the `TyClosure`;
|
||||||
|
/// - for generators, this is the `TyGenerator`;
|
||||||
|
/// - for constants, this is the type of value that gets produced.
|
||||||
|
/// - FIXME. Constants are handled somewhat inelegantly; this gets
|
||||||
|
/// patched in a later PR that has already landed on nll-master.
|
||||||
|
///
|
||||||
|
/// The key feature of the "defining type" is that it contains the
|
||||||
|
/// information needed to derive all the universal regions that
|
||||||
|
/// are in scope as well as the types of the inputs/output from
|
||||||
|
/// the MIR. In general, early-bound universal regions appear free
|
||||||
|
/// in the defining type and late-bound regions appear bound in
|
||||||
|
/// the signature.
|
||||||
fn defining_ty(&self) -> ty::Ty<'tcx> {
|
fn defining_ty(&self) -> ty::Ty<'tcx> {
|
||||||
let tcx = self.infcx.tcx;
|
let tcx = self.infcx.tcx;
|
||||||
let closure_base_def_id = tcx.closure_base_def_id(self.mir_def_id);
|
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> {
|
||||||
.replace_free_regions_with_nll_infer_vars(FR, &defining_ty)
|
.replace_free_regions_with_nll_infer_vars(FR, &defining_ty)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Builds a hashmap that maps from the universal regions that are
|
||||||
|
/// in scope (as a `ty::Region<'tcx>`) to their indices (as a
|
||||||
|
/// `RegionVid`). The map returned by this function contains only
|
||||||
|
/// the early-bound regions.
|
||||||
fn compute_indices(
|
fn compute_indices(
|
||||||
&self,
|
&self,
|
||||||
fr_static: RegionVid,
|
fr_static: RegionVid,
|
||||||
|
@ -490,6 +509,7 @@ impl<'cx, 'gcx, 'tcx> UniversalRegionsBuilder<'cx, 'gcx, 'tcx> {
|
||||||
// that correspond to early-bound regions declared on
|
// that correspond to early-bound regions declared on
|
||||||
// the `closure_base_def_id`.
|
// the `closure_base_def_id`.
|
||||||
assert!(substs.substs.len() >= identity_substs.len());
|
assert!(substs.substs.len() >= identity_substs.len());
|
||||||
|
assert_eq!(substs.substs.regions().count(), identity_substs.regions().count());
|
||||||
substs.substs
|
substs.substs
|
||||||
}
|
}
|
||||||
ty::TyFnDef(_, substs) => substs,
|
ty::TyFnDef(_, substs) => substs,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue