Skip to content

Commit 1ca9eb8

Browse files
committed
Remove ReEmpty
1 parent dd0335a commit 1ca9eb8

File tree

27 files changed

+64
-256
lines changed

27 files changed

+64
-256
lines changed

compiler/rustc_borrowck/src/diagnostics/region_name.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -357,11 +357,7 @@ impl<'tcx> MirBorrowckCtxt<'_, 'tcx> {
357357
ty::BoundRegionKind::BrAnon(_) => None,
358358
},
359359

360-
ty::ReLateBound(..)
361-
| ty::ReVar(..)
362-
| ty::RePlaceholder(..)
363-
| ty::ReEmpty(_)
364-
| ty::ReErased => None,
360+
ty::ReLateBound(..) | ty::ReVar(..) | ty::RePlaceholder(..) | ty::ReErased => None,
365361
}
366362
}
367363

compiler/rustc_borrowck/src/region_infer/opaque_types.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -486,9 +486,9 @@ impl<'tcx> TypeFolder<'tcx> for ReverseMapper<'tcx> {
486486
ty::ReErased => return r,
487487

488488
// The regions that we expect from borrow checking.
489-
ty::ReEarlyBound(_) | ty::ReFree(_) | ty::ReEmpty(ty::UniverseIndex::ROOT) => {}
489+
ty::ReEarlyBound(_) | ty::ReFree(_) => {}
490490

491-
ty::ReEmpty(_) | ty::RePlaceholder(_) | ty::ReVar(_) => {
491+
ty::RePlaceholder(_) | ty::ReVar(_) => {
492492
// All of the regions in the type should either have been
493493
// erased by writeback, or mapped back to named regions by
494494
// borrow checking.

compiler/rustc_borrowck/src/type_check/free_region_relations.rs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -347,13 +347,6 @@ impl<'tcx> UniversalRegionRelationsBuilder<'_, 'tcx> {
347347

348348
match outlives_bound {
349349
OutlivesBound::RegionSubRegion(r1, r2) => {
350-
// `where Type:` is lowered to `where Type: 'empty` so that
351-
// we check `Type` is well formed, but there's no use for
352-
// this bound here.
353-
if r1.is_empty() {
354-
return;
355-
}
356-
357350
// The bound says that `r1 <= r2`; we store `r2: r1`.
358351
let r1 = self.universal_regions.to_region_vid(r1);
359352
let r2 = self.universal_regions.to_region_vid(r2);

compiler/rustc_borrowck/src/universal_regions.rs

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -54,13 +54,6 @@ pub struct UniversalRegions<'tcx> {
5454
/// The total number of universal region variables instantiated.
5555
num_universals: usize,
5656

57-
/// A special region variable created for the `'empty(U0)` region.
58-
/// Note that this is **not** a "universal" region, as it doesn't
59-
/// represent a universally bound placeholder or any such thing.
60-
/// But we do create it here in this type because it's a useful region
61-
/// to have around in a few limited cases.
62-
pub root_empty: RegionVid,
63-
6457
/// The "defining" type for this function, with all universal
6558
/// regions instantiated. For a closure or generator, this is the
6659
/// closure type, but for a top-level function it's the `FnDef`.
@@ -323,11 +316,7 @@ impl<'tcx> UniversalRegions<'tcx> {
323316

324317
/// See `UniversalRegionIndices::to_region_vid`.
325318
pub fn to_region_vid(&self, r: ty::Region<'tcx>) -> RegionVid {
326-
if let ty::ReEmpty(ty::UniverseIndex::ROOT) = *r {
327-
self.root_empty
328-
} else {
329-
self.indices.to_region_vid(r)
330-
}
319+
self.indices.to_region_vid(r)
331320
}
332321

333322
/// As part of the NLL unit tests, you can annotate a function with
@@ -501,16 +490,10 @@ impl<'cx, 'tcx> UniversalRegionsBuilder<'cx, 'tcx> {
501490
_ => None,
502491
};
503492

504-
let root_empty = self
505-
.infcx
506-
.next_nll_region_var(NllRegionVariableOrigin::Existential { from_forall: true })
507-
.to_region_vid();
508-
509493
UniversalRegions {
510494
indices,
511495
fr_static,
512496
fr_fn_body,
513-
root_empty,
514497
first_extern_index,
515498
first_local_index,
516499
num_universals,

compiler/rustc_infer/src/errors/note_and_explain.rs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,6 @@ impl<'a> DescriptionCtx<'a> {
2727
me.kind = "restatic";
2828
}
2929

30-
ty::ReEmpty(ty::UniverseIndex::ROOT) => me.kind = "reempty",
31-
32-
ty::ReEmpty(ui) => {
33-
me.kind = "reemptyuni";
34-
me.arg = format!("{:?}", ui);
35-
}
36-
3730
ty::RePlaceholder(_) => return None,
3831

3932
// FIXME(#13998) RePlaceholder should probably print like

compiler/rustc_infer/src/infer/canonical/canonicalizer.rs

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -180,11 +180,7 @@ impl CanonicalizeMode for CanonicalizeQueryResponse {
180180
r: ty::Region<'tcx>,
181181
) -> ty::Region<'tcx> {
182182
match *r {
183-
ty::ReFree(_)
184-
| ty::ReErased
185-
| ty::ReStatic
186-
| ty::ReEmpty(ty::UniverseIndex::ROOT)
187-
| ty::ReEarlyBound(..) => r,
183+
ty::ReFree(_) | ty::ReErased | ty::ReStatic | ty::ReEarlyBound(..) => r,
188184

189185
ty::RePlaceholder(placeholder) => canonicalizer.canonical_var_for_region(
190186
CanonicalVarInfo { kind: CanonicalVarKind::PlaceholderRegion(placeholder) },
@@ -199,10 +195,6 @@ impl CanonicalizeMode for CanonicalizeQueryResponse {
199195
)
200196
}
201197

202-
ty::ReEmpty(ui) => {
203-
bug!("canonicalizing 'empty in universe {:?}", ui) // FIXME
204-
}
205-
206198
_ => {
207199
// Other than `'static` or `'empty`, the query
208200
// response should be executing in a fully
@@ -381,7 +373,6 @@ impl<'cx, 'tcx> TypeFolder<'tcx> for Canonicalizer<'cx, 'tcx> {
381373
ty::ReStatic
382374
| ty::ReEarlyBound(..)
383375
| ty::ReFree(_)
384-
| ty::ReEmpty(_)
385376
| ty::RePlaceholder(..)
386377
| ty::ReErased => self.canonicalize_mode.canonicalize_free_region(self, r),
387378
}

compiler/rustc_infer/src/infer/combine.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -688,7 +688,6 @@ impl<'tcx> TypeRelation<'tcx> for Generalizer<'_, 'tcx> {
688688

689689
ty::RePlaceholder(..)
690690
| ty::ReVar(..)
691-
| ty::ReEmpty(_)
692691
| ty::ReStatic
693692
| ty::ReEarlyBound(..)
694693
| ty::ReFree(..) => {
@@ -900,7 +899,6 @@ impl<'tcx> TypeRelation<'tcx> for ConstInferUnifier<'_, 'tcx> {
900899

901900
ty::RePlaceholder(..)
902901
| ty::ReVar(..)
903-
| ty::ReEmpty(_)
904902
| ty::ReStatic
905903
| ty::ReEarlyBound(..)
906904
| ty::ReFree(..) => {

compiler/rustc_infer/src/infer/error_reporting/mod.rs

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -96,11 +96,6 @@ pub(super) fn note_and_explain_region<'tcx>(
9696
msg_span_from_free_region(tcx, region, alt_span)
9797
}
9898

99-
ty::ReEmpty(ty::UniverseIndex::ROOT) => ("the empty lifetime".to_owned(), alt_span),
100-
101-
// uh oh, hope no user ever sees THIS
102-
ty::ReEmpty(ui) => (format!("the empty lifetime in universe {:?}", ui), alt_span),
103-
10499
ty::RePlaceholder(_) => return,
105100

106101
// FIXME(#13998) RePlaceholder should probably print like
@@ -139,8 +134,6 @@ fn msg_span_from_free_region<'tcx>(
139134
(msg, Some(span))
140135
}
141136
ty::ReStatic => ("the static lifetime".to_owned(), alt_span),
142-
ty::ReEmpty(ty::UniverseIndex::ROOT) => ("an empty lifetime".to_owned(), alt_span),
143-
ty::ReEmpty(ui) => (format!("an empty lifetime in universe {:?}", ui), alt_span),
144137
_ => bug!("{:?}", region),
145138
}
146139
}
@@ -250,17 +243,7 @@ pub fn unexpected_hidden_region_diagnostic<'tcx>(
250243

251244
// Explain the region we are capturing.
252245
match *hidden_region {
253-
ty::ReEmpty(ty::UniverseIndex::ROOT) => {
254-
// All lifetimes shorter than the function body are `empty` in
255-
// lexical region resolution. The default explanation of "an empty
256-
// lifetime" isn't really accurate here.
257-
let message = format!(
258-
"hidden type `{}` captures lifetime smaller than the function body",
259-
hidden_ty
260-
);
261-
err.span_note(span, &message);
262-
}
263-
ty::ReEarlyBound(_) | ty::ReFree(_) | ty::ReStatic | ty::ReEmpty(_) => {
246+
ty::ReEarlyBound(_) | ty::ReFree(_) | ty::ReStatic => {
264247
// Assuming regionck succeeded (*), we ought to always be
265248
// capturing *some* region from the fn header, and hence it
266249
// ought to be free. So under normal circumstances, we will go

compiler/rustc_infer/src/infer/freshen.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,6 @@ impl<'a, 'tcx> TypeFolder<'tcx> for TypeFreshener<'a, 'tcx> {
126126
| ty::ReFree(_)
127127
| ty::ReVar(_)
128128
| ty::RePlaceholder(..)
129-
| ty::ReEmpty(_)
130129
| ty::ReErased => {
131130
// replace all free regions with 'erased
132131
self.tcx().lifetimes.re_erased

compiler/rustc_infer/src/infer/lexical_region_resolve/mod.rs

Lines changed: 4 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use rustc_data_structures::intern::Interned;
1616
use rustc_index::vec::{Idx, IndexVec};
1717
use rustc_middle::ty::fold::TypeFoldable;
1818
use rustc_middle::ty::{self, Ty, TyCtxt};
19-
use rustc_middle::ty::{ReEarlyBound, ReEmpty, ReErased, ReFree, ReStatic};
19+
use rustc_middle::ty::{ReEarlyBound, ReErased, ReFree, ReStatic};
2020
use rustc_middle::ty::{ReLateBound, RePlaceholder, ReVar};
2121
use rustc_middle::ty::{Region, RegionVid};
2222
use rustc_span::Span;
@@ -261,13 +261,6 @@ impl<'cx, 'tcx> LexicalResolver<'cx, 'tcx> {
261261
cur_region
262262
}
263263

264-
ReEmpty(b_ui) => {
265-
// Empty regions are ordered according to the universe
266-
// they are associated with.
267-
let ui = a_universe.min(b_ui);
268-
self.tcx().mk_region(ReEmpty(ui))
269-
}
270-
271264
RePlaceholder(placeholder) => {
272265
// If the empty and placeholder regions are in the same universe,
273266
// then the LUB is the Placeholder region (which is the cur_region).
@@ -399,13 +392,6 @@ impl<'cx, 'tcx> LexicalResolver<'cx, 'tcx> {
399392
a_region
400393
}
401394

402-
ReEmpty(a_ui) => {
403-
// Empty regions are ordered according to the universe
404-
// they are associated with.
405-
let ui = a_ui.min(empty_ui);
406-
self.tcx().mk_region(ReEmpty(ui))
407-
}
408-
409395
RePlaceholder(placeholder) => {
410396
// If this empty region is from a universe that can
411397
// name the placeholder, then the placeholder is
@@ -428,9 +414,6 @@ impl<'cx, 'tcx> LexicalResolver<'cx, 'tcx> {
428414
// check below for a common case, here purely as an
429415
// optimization.
430416
let b_universe = self.var_infos[b_vid].universe;
431-
if let ReEmpty(a_universe) = *a_region && a_universe == b_universe {
432-
return false;
433-
}
434417

435418
let mut lub = self.lub_concrete_regions(a_region, cur_region);
436419
if lub == cur_region {
@@ -470,7 +453,7 @@ impl<'cx, 'tcx> LexicalResolver<'cx, 'tcx> {
470453
// they are associated with.
471454
a_ui.min(b_ui) == b_ui
472455
}
473-
(VarValue::Value(a), VarValue::Empty(b_ui)) => {
456+
(VarValue::Value(a), VarValue::Empty(_)) => {
474457
match *a {
475458
ReLateBound(..) | ReErased => {
476459
bug!("cannot relate region: {:?}", a);
@@ -493,12 +476,6 @@ impl<'cx, 'tcx> LexicalResolver<'cx, 'tcx> {
493476
false
494477
}
495478

496-
ReEmpty(a_ui) => {
497-
// Empty regions are ordered according to the universe
498-
// they are associated with.
499-
a_ui.min(b_ui) == b_ui
500-
}
501-
502479
RePlaceholder(_) => {
503480
// The LUB is either `a` or `'static`
504481
false
@@ -526,12 +503,6 @@ impl<'cx, 'tcx> LexicalResolver<'cx, 'tcx> {
526503
true
527504
}
528505

529-
ReEmpty(b_ui) => {
530-
// Empty regions are ordered according to the universe
531-
// they are associated with.
532-
a_ui.min(b_ui) == b_ui
533-
}
534-
535506
RePlaceholder(placeholder) => {
536507
// If this empty region is from a universe that can
537508
// name the placeholder, then the placeholder is
@@ -599,37 +570,6 @@ impl<'cx, 'tcx> LexicalResolver<'cx, 'tcx> {
599570
self.tcx().lifetimes.re_static
600571
}
601572

602-
(ReEmpty(_), ReEarlyBound(_) | ReFree(_)) => {
603-
// All empty regions are less than early-bound, free,
604-
// and scope regions.
605-
b
606-
}
607-
608-
(ReEarlyBound(_) | ReFree(_), ReEmpty(_)) => {
609-
// All empty regions are less than early-bound, free,
610-
// and scope regions.
611-
a
612-
}
613-
614-
(ReEmpty(a_ui), ReEmpty(b_ui)) => {
615-
// Empty regions are ordered according to the universe
616-
// they are associated with.
617-
let ui = a_ui.min(b_ui);
618-
self.tcx().mk_region(ReEmpty(ui))
619-
}
620-
621-
(ReEmpty(empty_ui), RePlaceholder(placeholder))
622-
| (RePlaceholder(placeholder), ReEmpty(empty_ui)) => {
623-
// If this empty region is from a universe that can
624-
// name the placeholder, then the placeholder is
625-
// larger; otherwise, the only ancestor is `'static`.
626-
if empty_ui.can_name(placeholder.universe) {
627-
self.tcx().mk_region(RePlaceholder(placeholder))
628-
} else {
629-
self.tcx().lifetimes.re_static
630-
}
631-
}
632-
633573
(ReEarlyBound(_) | ReFree(_), ReEarlyBound(_) | ReFree(_)) => {
634574
self.region_rels.lub_free_regions(a, b)
635575
}
@@ -1088,9 +1028,9 @@ impl<'cx, 'tcx> LexicalResolver<'cx, 'tcx> {
10881028
ty::ReVar(rid) => match var_values.values[rid] {
10891029
VarValue::ErrorValue => false,
10901030
VarValue::Empty(_) => true,
1091-
VarValue::Value(min) => matches!(*min, ty::ReEmpty(_)),
1031+
VarValue::Value(_) => false,
10921032
},
1093-
_ => matches!(*min, ty::ReEmpty(_)),
1033+
_ => false,
10941034
},
10951035

10961036
VerifyBound::AnyBound(bs) => {

compiler/rustc_infer/src/infer/region_constraints/mod.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -699,7 +699,6 @@ impl<'tcx> RegionConstraintCollector<'_, 'tcx> {
699699
ty::ReStatic | ty::ReErased | ty::ReFree(..) | ty::ReEarlyBound(..) => {
700700
ty::UniverseIndex::ROOT
701701
}
702-
ty::ReEmpty(ui) => ui,
703702
ty::RePlaceholder(placeholder) => placeholder.universe,
704703
ty::ReVar(vid) => self.var_universe(vid),
705704
ty::ReLateBound(..) => bug!("universe(): encountered bound region {:?}", region),

compiler/rustc_middle/src/ty/print/pretty.rs

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1978,7 +1978,7 @@ impl<'tcx> PrettyPrinter<'tcx> for FmtPrinter<'_, 'tcx> {
19781978

19791979
ty::ReVar(_) | ty::ReErased => false,
19801980

1981-
ty::ReStatic | ty::ReEmpty(_) => true,
1981+
ty::ReStatic => true,
19821982
}
19831983
}
19841984

@@ -2062,14 +2062,6 @@ impl<'tcx> FmtPrinter<'_, 'tcx> {
20622062
p!("'static");
20632063
return Ok(self);
20642064
}
2065-
ty::ReEmpty(ty::UniverseIndex::ROOT) => {
2066-
p!("'<empty>");
2067-
return Ok(self);
2068-
}
2069-
ty::ReEmpty(ui) => {
2070-
p!(write("'<empty:{:?}>", ui));
2071-
return Ok(self);
2072-
}
20732065
}
20742066

20752067
p!("'_");

compiler/rustc_middle/src/ty/sty.rs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1511,7 +1511,6 @@ impl<'tcx> Region<'tcx> {
15111511
ty::ReStatic => true,
15121512
ty::ReVar(..) => false,
15131513
ty::RePlaceholder(placeholder) => placeholder.name.is_named(),
1514-
ty::ReEmpty(_) => false,
15151514
ty::ReErased => false,
15161515
}
15171516
}
@@ -1536,11 +1535,6 @@ impl<'tcx> Region<'tcx> {
15361535
matches!(*self, ty::RePlaceholder(..))
15371536
}
15381537

1539-
#[inline]
1540-
pub fn is_empty(self) -> bool {
1541-
matches!(*self, ty::ReEmpty(..))
1542-
}
1543-
15441538
#[inline]
15451539
pub fn bound_at_or_above_binder(self, index: ty::DebruijnIndex) -> bool {
15461540
match *self {
@@ -1572,7 +1566,7 @@ impl<'tcx> Region<'tcx> {
15721566
flags = flags | TypeFlags::HAS_FREE_REGIONS;
15731567
flags = flags | TypeFlags::HAS_FREE_LOCAL_REGIONS;
15741568
}
1575-
ty::ReEmpty(_) | ty::ReStatic => {
1569+
ty::ReStatic => {
15761570
flags = flags | TypeFlags::HAS_FREE_REGIONS;
15771571
}
15781572
ty::ReLateBound(..) => {

compiler/rustc_symbol_mangling/src/typeid/typeid_itanium_cxx_abi.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -305,8 +305,7 @@ fn encode_region<'tcx>(
305305
| RegionKind::ReFree(..)
306306
| RegionKind::ReStatic
307307
| RegionKind::ReVar(..)
308-
| RegionKind::RePlaceholder(..)
309-
| RegionKind::ReEmpty(..) => {
308+
| RegionKind::RePlaceholder(..) => {
310309
bug!("encode_region: unexpected `{:?}`", region.kind());
311310
}
312311
}

0 commit comments

Comments
 (0)