diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/librustc/ich/impls_ty.rs | 3 | ||||
| -rw-r--r-- | src/librustc/infer/combine.rs | 8 | ||||
| -rw-r--r-- | src/librustc/infer/error_reporting/mod.rs | 8 | ||||
| -rw-r--r-- | src/librustc/infer/freshen.rs | 7 | ||||
| -rw-r--r-- | src/librustc/infer/lexical_region_resolve/mod.rs | 7 | ||||
| -rw-r--r-- | src/librustc/mir/mod.rs | 9 | ||||
| -rw-r--r-- | src/librustc/ty/sty.rs | 9 | ||||
| -rw-r--r-- | src/librustc/ty/util.rs | 2 | ||||
| -rw-r--r-- | src/librustc/util/ppaux.rs | 8 | ||||
| -rw-r--r-- | src/librustc_borrowck/borrowck/gather_loans/mod.rs | 1 | ||||
| -rw-r--r-- | src/librustc_mir/borrow_check/error_reporting.rs | 1 | ||||
| -rw-r--r-- | src/librustc_typeck/variance/constraints.rs | 1 | ||||
| -rw-r--r-- | src/librustdoc/clean/mod.rs | 1 |
13 files changed, 64 insertions, 1 deletions
diff --git a/src/librustc/ich/impls_ty.rs b/src/librustc/ich/impls_ty.rs index 2655e2acbbd..ea3a1074aa2 100644 --- a/src/librustc/ich/impls_ty.rs +++ b/src/librustc/ich/impls_ty.rs @@ -75,6 +75,9 @@ for ty::RegionKind { 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(..) => { diff --git a/src/librustc/infer/combine.rs b/src/librustc/infer/combine.rs index 50a37e12531..f7bc092a3d7 100644 --- a/src/librustc/infer/combine.rs +++ b/src/librustc/infer/combine.rs @@ -475,6 +475,14 @@ impl<'cx, 'gcx, 'tcx> TypeRelation<'cx, 'gcx, 'tcx> for Generalizer<'cx, 'gcx, ' 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 diff --git a/src/librustc/infer/error_reporting/mod.rs b/src/librustc/infer/error_reporting/mod.rs index 514b29120a9..3e3aea0256e 100644 --- a/src/librustc/infer/error_reporting/mod.rs +++ b/src/librustc/infer/error_reporting/mod.rs @@ -240,6 +240,14 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { 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 { diff --git a/src/librustc/infer/freshen.rs b/src/librustc/infer/freshen.rs index 426c61e9ac0..1783d5abfc7 100644 --- a/src/librustc/infer/freshen.rs +++ b/src/librustc/infer/freshen.rs @@ -113,6 +113,13 @@ impl<'a, 'gcx, 'tcx> TypeFolder<'gcx, 'tcx> for TypeFreshener<'a, 'gcx, 'tcx> { // replace all free regions with 'erased self.tcx().types.re_erased } + + ty::ReClosureBound(..) => { + bug!( + "encountered unexpected ReClosureBound: {:?}", + r, + ); + } } } diff --git a/src/librustc/infer/lexical_region_resolve/mod.rs b/src/librustc/infer/lexical_region_resolve/mod.rs index 5a4f2157298..3ac4ec5bee4 100644 --- a/src/librustc/infer/lexical_region_resolve/mod.rs +++ b/src/librustc/infer/lexical_region_resolve/mod.rs @@ -258,7 +258,12 @@ impl<'cx, 'gcx, 'tcx> LexicalResolver<'cx, 'gcx, 'tcx> { 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); } diff --git a/src/librustc/mir/mod.rs b/src/librustc/mir/mod.rs index d7afce7de46..dd3dd1e06de 100644 --- a/src/librustc/mir/mod.rs +++ b/src/librustc/mir/mod.rs @@ -1831,6 +1831,15 @@ pub struct GeneratorLayout<'tcx> { /// 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 diff --git a/src/librustc/ty/sty.rs b/src/librustc/ty/sty.rs index 2f72b3dde42..02729c6d600 100644 --- a/src/librustc/ty/sty.rs +++ b/src/librustc/ty/sty.rs @@ -1036,6 +1036,12 @@ pub enum RegionKind { /// 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> {} @@ -1207,6 +1213,9 @@ impl RegionKind { } ty::ReErased => { } + ty::ReClosureBound(..) => { + flags = flags | TypeFlags::HAS_FREE_REGIONS; + } } match *self { diff --git a/src/librustc/ty/util.rs b/src/librustc/ty/util.rs index 2e9e45c9ffe..84d5f547f1b 100644 --- a/src/librustc/ty/util.rs +++ b/src/librustc/ty/util.rs @@ -822,6 +822,8 @@ impl<'a, 'gcx, 'tcx, W> TypeVisitor<'tcx> for TypeIdHasher<'a, 'gcx, 'tcx, W> ty::ReEarlyBound(ty::EarlyBoundRegion { def_id, .. }) => { self.def_id(def_id); } + + ty::ReClosureBound(..) | ty::ReLateBound(..) | ty::ReFree(..) | ty::ReScope(..) | diff --git a/src/librustc/util/ppaux.rs b/src/librustc/util/ppaux.rs index 9ff3d73f5c4..5bfa6464568 100644 --- a/src/librustc/util/ppaux.rs +++ b/src/librustc/util/ppaux.rs @@ -733,6 +733,9 @@ define_print! { 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 { @@ -743,6 +746,11 @@ define_print! { data.name) } + ty::ReClosureBound(ref vid) => { + write!(f, "ReClosureBound({:?})", + vid) + } + ty::ReLateBound(binder_id, ref bound_region) => { write!(f, "ReLateBound({:?}, {:?})", binder_id, diff --git a/src/librustc_borrowck/borrowck/gather_loans/mod.rs b/src/librustc_borrowck/borrowck/gather_loans/mod.rs index 8654f2a50e4..5cbe2822e5c 100644 --- a/src/librustc_borrowck/borrowck/gather_loans/mod.rs +++ b/src/librustc_borrowck/borrowck/gather_loans/mod.rs @@ -367,6 +367,7 @@ impl<'a, 'tcx> GatherLoanCtxt<'a, 'tcx> { ty::ReStatic => self.item_ub, ty::ReEmpty | + ty::ReClosureBound(..) | ty::ReLateBound(..) | ty::ReVar(..) | ty::ReSkolemized(..) | diff --git a/src/librustc_mir/borrow_check/error_reporting.rs b/src/librustc_mir/borrow_check/error_reporting.rs index 31a94499fd0..2c0fa9878aa 100644 --- a/src/librustc_mir/borrow_check/error_reporting.rs +++ b/src/librustc_mir/borrow_check/error_reporting.rs @@ -381,6 +381,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> { }, (RegionKind::ReLateBound(_, _), _) | (RegionKind::ReSkolemized(_, _), _) | + (RegionKind::ReClosureBound(_), _) | (RegionKind::ReErased, _) => { span_bug!(drop_span, "region does not make sense in this context"); }, diff --git a/src/librustc_typeck/variance/constraints.rs b/src/librustc_typeck/variance/constraints.rs index ef6552c8e33..df42d5eaa0a 100644 --- a/src/librustc_typeck/variance/constraints.rs +++ b/src/librustc_typeck/variance/constraints.rs @@ -465,6 +465,7 @@ impl<'a, 'tcx> ConstraintContext<'a, 'tcx> { } ty::ReFree(..) | + ty::ReClosureBound(..) | ty::ReScope(..) | ty::ReVar(..) | ty::ReSkolemized(..) | diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs index 91908de98a6..c7657c9b2ff 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -1055,6 +1055,7 @@ impl Clean<Option<Lifetime>> for ty::RegionKind { ty::ReVar(..) | ty::ReSkolemized(..) | ty::ReEmpty | + ty::ReClosureBound(_) | ty::ReErased => None } } |
