ty::ReFree(ref free_region) => {
free_region.hash_stable(hcx, hasher);
}
+ ty::ReClosureBound(vid) => {
+ vid.hash_stable(hcx, hasher);
+ }
ty::ReLateBound(..) |
ty::ReVar(..) |
ty::ReSkolemized(..) => {
ty::Bivariant | ty::Covariant | ty::Contravariant => (),
}
}
+
+ ty::ReClosureBound(..) => {
+ span_bug!(
+ self.span,
+ "encountered unexpected ReClosureBound: {:?}",
+ r,
+ );
+ }
}
// FIXME: This is non-ideal because we don't give a
ty::ReErased => {
(format!("lifetime {:?}", region), None)
}
+
+ // We shouldn't encounter an error message with ReClosureBound.
+ ty::ReClosureBound(..) => {
+ bug!(
+ "encountered unexpected ReClosureBound: {:?}",
+ region,
+ );
+ }
};
let message = format!("{}{}{}", prefix, description, suffix);
if let Some(span) = span {
// replace all free regions with 'erased
self.tcx().types.re_erased
}
+
+ ty::ReClosureBound(..) => {
+ bug!(
+ "encountered unexpected ReClosureBound: {:?}",
+ r,
+ );
+ }
}
}
fn lub_concrete_regions(&self, a: Region<'tcx>, b: Region<'tcx>) -> Region<'tcx> {
let tcx = self.region_rels.tcx;
match (a, b) {
- (&ReLateBound(..), _) | (_, &ReLateBound(..)) | (&ReErased, _) | (_, &ReErased) => {
+ (&ty::ReClosureBound(..), _) |
+ (_, &ty::ReClosureBound(..)) |
+ (&ReLateBound(..), _) |
+ (_, &ReLateBound(..)) |
+ (&ReErased, _) |
+ (_, &ReErased) => {
bug!("cannot relate region: LUB({:?}, {:?})", a, b);
}
/// instance of the closure is created, the corresponding free regions
/// can be extracted from its type and constrained to have the given
/// outlives relationship.
+///
+/// In some cases, we have to record outlives requirements between
+/// types and regions as well. In that case, if those types include
+/// any regions, those regions are recorded as `ReClosureBound`
+/// instances assigned one of these same indices. Those regions will
+/// be substituted away by the creator. We use `ReClosureBound` in
+/// that case because the regions must be allocated in the global
+/// TyCtxt, and hence we cannot use `ReVar` (which is what we use
+/// internally within the rest of the NLL code).
#[derive(Clone, Debug, RustcEncodable, RustcDecodable)]
pub struct ClosureRegionRequirements<'gcx> {
/// The number of external regions defined on the closure. In our
/// Erased region, used by trait selection, in MIR and during trans.
ReErased,
+
+ /// These are regions bound in the "defining type" for a
+ /// closure. They are used ONLY as part of the
+ /// `ClosureRegionRequirements` that are produced by MIR borrowck.
+ /// See `ClosureRegionRequirements` for more details.
+ ReClosureBound(RegionVid),
}
impl<'tcx> serialize::UseSpecializedDecodable for Region<'tcx> {}
}
ty::ReErased => {
}
+ ty::ReClosureBound(..) => {
+ flags = flags | TypeFlags::HAS_FREE_REGIONS;
+ }
}
match *self {
ty::ReEarlyBound(ty::EarlyBoundRegion { def_id, .. }) => {
self.def_id(def_id);
}
+
+ ty::ReClosureBound(..) |
ty::ReLateBound(..) |
ty::ReFree(..) |
ty::ReScope(..) |
ty::ReErased => Ok(()),
ty::ReStatic => write!(f, "'static"),
ty::ReEmpty => write!(f, "'<empty>"),
+
+ // The user should never encounter these in unsubstituted form.
+ ty::ReClosureBound(vid) => write!(f, "{:?}", vid),
}
}
debug {
data.name)
}
+ ty::ReClosureBound(ref vid) => {
+ write!(f, "ReClosureBound({:?})",
+ vid)
+ }
+
ty::ReLateBound(binder_id, ref bound_region) => {
write!(f, "ReLateBound({:?}, {:?})",
binder_id,
ty::ReStatic => self.item_ub,
ty::ReEmpty |
+ ty::ReClosureBound(..) |
ty::ReLateBound(..) |
ty::ReVar(..) |
ty::ReSkolemized(..) |
},
(RegionKind::ReLateBound(_, _), _) |
(RegionKind::ReSkolemized(_, _), _) |
+ (RegionKind::ReClosureBound(_), _) |
(RegionKind::ReErased, _) => {
span_bug!(drop_span, "region does not make sense in this context");
},
}
ty::ReFree(..) |
+ ty::ReClosureBound(..) |
ty::ReScope(..) |
ty::ReVar(..) |
ty::ReSkolemized(..) |
ty::ReVar(..) |
ty::ReSkolemized(..) |
ty::ReEmpty |
+ ty::ReClosureBound(_) |
ty::ReErased => None
}
}