Skip to content

Commit c3b9881

Browse files
committed
Remove ReClosureBound
1 parent 660326e commit c3b9881

File tree

20 files changed

+50
-129
lines changed

20 files changed

+50
-129
lines changed

src/librustc/ich/impls_ty.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,6 @@ impl<'a> HashStable<StableHashingContext<'a>> for ty::RegionKind {
9292
ty::ReFree(ref free_region) => {
9393
free_region.hash_stable(hcx, hasher);
9494
}
95-
ty::ReClosureBound(vid) => {
96-
vid.hash_stable(hcx, hasher);
97-
}
9895
ty::ReVar(..) | ty::RePlaceholder(..) => {
9996
bug!("StableHasher: unexpected region {:?}", *self)
10097
}

src/librustc/mir/query.rs

Lines changed: 24 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -88,34 +88,35 @@ pub struct ConstQualifs {
8888
/// requirements are then verified and proved by the closure's
8989
/// creating function. This struct encodes those requirements.
9090
///
91-
/// The requirements are listed as being between various
92-
/// `RegionVid`. The 0th region refers to `'static`; subsequent region
93-
/// vids refer to the free regions that appear in the closure (or
94-
/// generator's) type, in order of appearance. (This numbering is
95-
/// actually defined by the `UniversalRegions` struct in the NLL
96-
/// region checker. See for example
97-
/// `UniversalRegions::closure_mapping`.) Note that we treat the free
98-
/// regions in the closure's type "as if" they were erased, so their
99-
/// precise identity is not important, only their position.
91+
/// The requirements are listed as being between various `RegionVid`. The 0th
92+
/// region refers to `'static`; subsequent region vids refer to the free
93+
/// regions that appear in the closure (or generator's) type, in order of
94+
/// appearance. (This numbering is actually defined by the `UniversalRegions`
95+
/// struct in the NLL region checker. See for example
96+
/// `UniversalRegions::closure_mapping`.) Note the free regions in the
97+
/// closure's signature and captures are erased.
10098
///
10199
/// Example: If type check produces a closure with the closure substs:
102100
///
103101
/// ```text
104102
/// ClosureSubsts = [
105-
/// i8, // the "closure kind"
106-
/// for<'x> fn(&'a &'x u32) -> &'x u32, // the "closure signature"
107-
/// &'a String, // some upvar
103+
/// 'a, // From the parent.
104+
/// 'b,
105+
/// i8, // the "closure kind"
106+
/// for<'x> fn(&'<erased> &'x u32) -> &'x u32, // the "closure signature"
107+
/// &'<erased> String, // some upvar
108108
/// ]
109109
/// ```
110110
///
111-
/// here, there is one unique free region (`'a`) but it appears
112-
/// twice. We would "renumber" each occurrence to a unique vid, as follows:
111+
/// We would "renumber" each free region to a unique vid, as follows:
113112
///
114113
/// ```text
115114
/// ClosureSubsts = [
116-
/// i8, // the "closure kind"
117-
/// for<'x> fn(&'1 &'x u32) -> &'x u32, // the "closure signature"
118-
/// &'2 String, // some upvar
115+
/// '1, // From the parent.
116+
/// '2,
117+
/// i8, // the "closure kind"
118+
/// for<'x> fn(&'3 &'x u32) -> &'x u32, // the "closure signature"
119+
/// &'4 String, // some upvar
119120
/// ]
120121
/// ```
121122
///
@@ -124,14 +125,12 @@ pub struct ConstQualifs {
124125
/// can be extracted from its type and constrained to have the given
125126
/// outlives relationship.
126127
///
127-
/// In some cases, we have to record outlives requirements between
128-
/// types and regions as well. In that case, if those types include
129-
/// any regions, those regions are recorded as `ReClosureBound`
130-
/// instances assigned one of these same indices. Those regions will
131-
/// be substituted away by the creator. We use `ReClosureBound` in
132-
/// that case because the regions must be allocated in the global
133-
/// `TyCtxt`, and hence we cannot use `ReVar` (which is what we use
134-
/// internally within the rest of the NLL code).
128+
/// In some cases, we have to record outlives requirements between types and
129+
/// regions as well. In that case, if those types include any regions, those
130+
/// regions are recorded using their external names (`ReStatic`,
131+
/// `ReEarlyBound`, `ReFree`). We use these because in a query response we
132+
/// cannot use `ReVar` (which is what we use internally within the rest of the
133+
/// NLL code).
135134
#[derive(Clone, Debug, RustcEncodable, RustcDecodable, HashStable)]
136135
pub struct ClosureRegionRequirements<'tcx> {
137136
/// The number of external regions defined on the closure. In our

src/librustc/ty/print/pretty.rs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1547,7 +1547,7 @@ impl<F: fmt::Write> PrettyPrinter<'tcx> for FmtPrinter<'_, 'tcx, F> {
15471547

15481548
ty::ReVar(_) | ty::ReScope(_) | ty::ReErased => false,
15491549

1550-
ty::ReStatic | ty::ReEmpty(_) | ty::ReClosureBound(_) => true,
1550+
ty::ReStatic | ty::ReEmpty(_) => true,
15511551
}
15521552
}
15531553

@@ -1659,12 +1659,6 @@ impl<F: fmt::Write> FmtPrinter<'_, '_, F> {
16591659
p!(write("'<empty:{:?}>", ui));
16601660
return Ok(self);
16611661
}
1662-
1663-
// The user should never encounter these in unsubstituted form.
1664-
ty::ReClosureBound(vid) => {
1665-
p!(write("{:?}", vid));
1666-
return Ok(self);
1667-
}
16681662
}
16691663

16701664
p!(write("'_"));

src/librustc/ty/structural_impls.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,6 @@ impl fmt::Debug for ty::RegionKind {
8181
match *self {
8282
ty::ReEarlyBound(ref data) => write!(f, "ReEarlyBound({}, {})", data.index, data.name),
8383

84-
ty::ReClosureBound(ref vid) => write!(f, "ReClosureBound({:?})", vid),
85-
8684
ty::ReLateBound(binder_id, ref bound_region) => {
8785
write!(f, "ReLateBound({:?}, {:?})", binder_id, bound_region)
8886
}

src/librustc/ty/sty.rs

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1442,12 +1442,6 @@ pub enum RegionKind {
14421442

14431443
/// Erased region, used by trait selection, in MIR and during codegen.
14441444
ReErased,
1445-
1446-
/// These are regions bound in the "defining type" for a
1447-
/// closure. They are used ONLY as part of the
1448-
/// `ClosureRegionRequirements` that are produced by MIR borrowck.
1449-
/// See `ClosureRegionRequirements` for more details.
1450-
ReClosureBound(RegionVid),
14511445
}
14521446

14531447
impl<'tcx> rustc_serialize::UseSpecializedDecodable for Region<'tcx> {}
@@ -1689,7 +1683,6 @@ impl RegionKind {
16891683
RegionKind::RePlaceholder(placeholder) => placeholder.name.is_named(),
16901684
RegionKind::ReEmpty(_) => false,
16911685
RegionKind::ReErased => false,
1692-
RegionKind::ReClosureBound(..) => false,
16931686
}
16941687
}
16951688

@@ -1770,9 +1763,6 @@ impl RegionKind {
17701763
ty::ReEmpty(_) | ty::ReStatic => {
17711764
flags = flags | TypeFlags::HAS_FREE_REGIONS;
17721765
}
1773-
ty::ReClosureBound(..) => {
1774-
flags = flags | TypeFlags::HAS_FREE_REGIONS;
1775-
}
17761766
ty::ReLateBound(..) => {
17771767
flags = flags | TypeFlags::HAS_RE_LATE_BOUND;
17781768
}

src/librustc_infer/infer/canonical/canonicalizer.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -336,10 +336,6 @@ impl<'cx, 'tcx> TypeFolder<'tcx> for Canonicalizer<'cx, 'tcx> {
336336
| ty::ReEmpty(_)
337337
| ty::RePlaceholder(..)
338338
| ty::ReErased => self.canonicalize_region_mode.canonicalize_free_region(self, r),
339-
340-
ty::ReClosureBound(..) => {
341-
bug!("closure bound region encountered during canonicalization");
342-
}
343339
}
344340
}
345341

src/librustc_infer/infer/combine.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -581,10 +581,6 @@ impl TypeRelation<'tcx> for Generalizer<'_, 'tcx> {
581581
return Ok(r);
582582
}
583583

584-
ty::ReClosureBound(..) => {
585-
span_bug!(self.span, "encountered unexpected ReClosureBound: {:?}", r,);
586-
}
587-
588584
ty::RePlaceholder(..)
589585
| ty::ReVar(..)
590586
| ty::ReEmpty(_)

src/librustc_infer/infer/error_reporting/mod.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -152,11 +152,6 @@ pub(super) fn note_and_explain_region(
152152
ty::ReVar(_) | ty::ReLateBound(..) | ty::ReErased => {
153153
(format!("lifetime {:?}", region), None)
154154
}
155-
156-
// We shouldn't encounter an error message with ReClosureBound.
157-
ty::ReClosureBound(..) => {
158-
bug!("encountered unexpected ReClosureBound: {:?}", region,);
159-
}
160155
};
161156

162157
emit_msg_span(err, prefix, description, span, suffix);

src/librustc_infer/infer/freshen.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -135,10 +135,6 @@ impl<'a, 'tcx> TypeFolder<'tcx> for TypeFreshener<'a, 'tcx> {
135135
// replace all free regions with 'erased
136136
self.tcx().lifetimes.re_erased
137137
}
138-
139-
ty::ReClosureBound(..) => {
140-
bug!("encountered unexpected region: {:?}", r,);
141-
}
142138
}
143139
}
144140

src/librustc_infer/infer/lexical_region_resolve/mod.rs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -464,12 +464,7 @@ impl<'cx, 'tcx> LexicalResolver<'cx, 'tcx> {
464464
/// term "concrete regions").
465465
fn lub_concrete_regions(&self, a: Region<'tcx>, b: Region<'tcx>) -> Region<'tcx> {
466466
let r = match (a, b) {
467-
(&ty::ReClosureBound(..), _)
468-
| (_, &ty::ReClosureBound(..))
469-
| (&ReLateBound(..), _)
470-
| (_, &ReLateBound(..))
471-
| (&ReErased, _)
472-
| (_, &ReErased) => {
467+
(&ReLateBound(..), _) | (_, &ReLateBound(..)) | (&ReErased, _) | (_, &ReErased) => {
473468
bug!("cannot relate region: LUB({:?}, {:?})", a, b);
474469
}
475470

0 commit comments

Comments
 (0)