Skip to content

Commit 7eca6c1

Browse files
Remove empty lifetime
1 parent cadaba9 commit 7eca6c1

File tree

12 files changed

+8
-108
lines changed

12 files changed

+8
-108
lines changed

chalk-engine/src/slg/resolvent.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -614,8 +614,7 @@ impl<'i, I: Interner> Zipper<I> for AnswerSubstitutor<'i, I> {
614614

615615
(LifetimeData::Static, LifetimeData::Static)
616616
| (LifetimeData::Placeholder(_), LifetimeData::Placeholder(_))
617-
| (LifetimeData::Erased, LifetimeData::Erased)
618-
| (LifetimeData::Empty(_), LifetimeData::Empty(_)) => {
617+
| (LifetimeData::Erased, LifetimeData::Erased) => {
619618
assert_eq!(answer, pending);
620619
Ok(())
621620
}
@@ -628,8 +627,7 @@ impl<'i, I: Interner> Zipper<I> for AnswerSubstitutor<'i, I> {
628627
(LifetimeData::Static, _)
629628
| (LifetimeData::BoundVar(_), _)
630629
| (LifetimeData::Placeholder(_), _)
631-
| (LifetimeData::Erased, _)
632-
| (LifetimeData::Empty(_), _) => panic!(
630+
| (LifetimeData::Erased, _) => panic!(
633631
"structural mismatch between answer `{:?}` and pending goal `{:?}`",
634632
answer, pending,
635633
),

chalk-integration/src/lowering.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -880,10 +880,6 @@ impl LowerWithEnv for Lifetime {
880880
interner,
881881
chalk_ir::LifetimeData::Static,
882882
)),
883-
Lifetime::Empty => Ok(chalk_ir::Lifetime::new(
884-
interner,
885-
chalk_ir::LifetimeData::Empty(chalk_ir::UniverseIndex { counter: 0 }),
886-
)),
887883
Lifetime::Erased => Ok(chalk_ir::Lifetime::new(
888884
interner,
889885
chalk_ir::LifetimeData::Erased,

chalk-ir/src/debug.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -306,8 +306,6 @@ impl<I: Interner> Debug for LifetimeData<I> {
306306
LifetimeData::InferenceVar(var) => write!(fmt, "'{:?}", var),
307307
LifetimeData::Placeholder(index) => write!(fmt, "'{:?}", index),
308308
LifetimeData::Static => write!(fmt, "'static"),
309-
LifetimeData::Empty(UniverseIndex::ROOT) => write!(fmt, "'<empty>"),
310-
LifetimeData::Empty(universe) => write!(fmt, "'<empty:{:?}>", universe),
311309
LifetimeData::Erased => write!(fmt, "'<erased>"),
312310
LifetimeData::Phantom(..) => unreachable!(),
313311
}

chalk-ir/src/fold.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -821,7 +821,6 @@ where
821821
folder.try_fold_free_placeholder_lifetime(*universe, outer_binder)
822822
}
823823
LifetimeData::Static => Ok(LifetimeData::<I>::Static.intern(folder.interner())),
824-
LifetimeData::Empty(ui) => Ok(LifetimeData::<I>::Empty(*ui).intern(folder.interner())),
825824
LifetimeData::Erased => Ok(LifetimeData::<I>::Erased.intern(folder.interner())),
826825
LifetimeData::Phantom(void, ..) => match *void {},
827826
}

chalk-ir/src/lib.rs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1278,7 +1278,6 @@ impl<I: Interner> Lifetime<I> {
12781278
LifetimeData::InferenceVar(_) => false,
12791279
LifetimeData::Placeholder(_) => false,
12801280
LifetimeData::Static => false,
1281-
LifetimeData::Empty(_) => false,
12821281
LifetimeData::Erased => false,
12831282
LifetimeData::Phantom(..) => unreachable!(),
12841283
}
@@ -1297,7 +1296,7 @@ impl<I: Interner> Lifetime<I> {
12971296
| TypeFlags::HAS_FREE_LOCAL_REGIONS
12981297
| TypeFlags::HAS_FREE_REGIONS
12991298
}
1300-
LifetimeData::Static | LifetimeData::Empty(_) => TypeFlags::HAS_FREE_REGIONS,
1299+
LifetimeData::Static => TypeFlags::HAS_FREE_REGIONS,
13011300
LifetimeData::Phantom(_, _) => TypeFlags::empty(),
13021301
LifetimeData::BoundVar(_) => TypeFlags::HAS_RE_LATE_BOUND,
13031302
LifetimeData::Erased => TypeFlags::HAS_RE_ERASED,
@@ -1316,11 +1315,6 @@ pub enum LifetimeData<I: Interner> {
13161315
Placeholder(PlaceholderIndex),
13171316
/// Static lifetime
13181317
Static,
1319-
/// An empty lifetime: a lifetime shorter than any other lifetime in a
1320-
/// universe with a lesser or equal index. The universe only non-zero in
1321-
/// lexical region resolve in rustc, so chalk shouldn't ever see a non-zero
1322-
/// index.
1323-
Empty(UniverseIndex),
13241318
/// An erased lifetime, used by rustc to improve caching when we doesn't
13251319
/// care about lifetimes
13261320
Erased,

chalk-ir/src/visit.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -330,9 +330,7 @@ impl<I: Interner> TypeSuperVisitable<I> for Lifetime<I> {
330330
LifetimeData::Placeholder(universe) => {
331331
visitor.visit_free_placeholder(*universe, outer_binder)
332332
}
333-
LifetimeData::Static | LifetimeData::Empty(_) | LifetimeData::Erased => {
334-
ControlFlow::Continue(())
335-
}
333+
LifetimeData::Static | LifetimeData::Erased => ControlFlow::Continue(()),
336334
LifetimeData::Phantom(void, ..) => match *void {},
337335
}
338336
}

chalk-parse/src/ast.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,6 @@ pub enum Lifetime {
391391
Id { name: Identifier },
392392
Static,
393393
Erased,
394-
Empty,
395394
}
396395

397396
#[derive(Clone, PartialEq, Eq, Debug)]

chalk-parse/src/parser.lalrpop

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -492,7 +492,6 @@ Lifetime: Lifetime = {
492492
<n:LifetimeId> => Lifetime::Id { name: n },
493493
"'static" => Lifetime::Static,
494494
"'erased" => Lifetime::Erased,
495-
"'empty" => Lifetime::Empty,
496495
};
497496

498497
ConstWithoutId: Const = {

chalk-solve/src/display/ty.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,6 @@ impl<I: Interner> RenderAsRust<I> for LifetimeData<I> {
240240
write!(f, "'_placeholder_{}_{}", ix.ui.counter, ix.idx)
241241
}
242242
LifetimeData::Static => write!(f, "'static"),
243-
LifetimeData::Empty(_) => write!(f, "'<empty>"),
244243
LifetimeData::Erased => write!(f, "'_"),
245244
// Matching the void ensures at compile time that this code is
246245
// unreachable

chalk-solve/src/infer/canonicalize.rs

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use crate::debug_span;
22
use chalk_derive::FallibleTypeFolder;
33
use chalk_ir::fold::shift::Shift;
4-
use chalk_ir::fold::{TypeFoldable, TypeFolder, TypeSuperFoldable};
4+
use chalk_ir::fold::{TypeFoldable, TypeFolder};
55
use chalk_ir::interner::{HasInterner, Interner};
66
use chalk_ir::*;
77
use std::cmp::max;
@@ -231,17 +231,6 @@ impl<'i, I: Interner> TypeFolder<I> for Canonicalizer<'i, I> {
231231
}
232232
}
233233

234-
fn fold_lifetime(&mut self, lifetime: Lifetime<I>, outer_binder: DebruijnIndex) -> Lifetime<I> {
235-
match *lifetime.data(self.interner) {
236-
LifetimeData::Empty(ui) if ui.counter != 0 => {
237-
// ReEmpty in non-root universes is only used by lexical region
238-
// inference. We shouldn't see it in canonicalization.
239-
panic!("Cannot canonicalize ReEmpty in non-root universe")
240-
}
241-
_ => lifetime.super_fold_with(self, outer_binder),
242-
}
243-
}
244-
245234
fn interner(&self) -> I {
246235
self.interner
247236
}

chalk-solve/src/infer/unify.rs

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -955,18 +955,12 @@ impl<'t, I: Interner> Unifier<'t, I> {
955955
(
956956
&LifetimeData::InferenceVar(a_var),
957957
&LifetimeData::Placeholder(PlaceholderIndex { ui, .. }),
958-
)
959-
| (&LifetimeData::InferenceVar(a_var), &LifetimeData::Empty(ui)) => {
960-
self.unify_lifetime_var(variance, a_var, b, ui)
961-
}
958+
) => self.unify_lifetime_var(variance, a_var, b, ui),
962959

963960
(
964961
&LifetimeData::Placeholder(PlaceholderIndex { ui, .. }),
965962
&LifetimeData::InferenceVar(b_var),
966-
)
967-
| (&LifetimeData::Empty(ui), &LifetimeData::InferenceVar(b_var)) => {
968-
self.unify_lifetime_var(variance.invert(), b_var, a, ui)
969-
}
963+
) => self.unify_lifetime_var(variance.invert(), b_var, a, ui),
970964

971965
(&LifetimeData::InferenceVar(a_var), &LifetimeData::Erased)
972966
| (&LifetimeData::InferenceVar(a_var), &LifetimeData::Static) => {
@@ -982,19 +976,12 @@ impl<'t, I: Interner> Unifier<'t, I> {
982976
| (&LifetimeData::Erased, &LifetimeData::Erased) => Ok(()),
983977

984978
(&LifetimeData::Static, &LifetimeData::Placeholder(_))
985-
| (&LifetimeData::Static, &LifetimeData::Empty(_))
986979
| (&LifetimeData::Static, &LifetimeData::Erased)
987980
| (&LifetimeData::Placeholder(_), &LifetimeData::Static)
988981
| (&LifetimeData::Placeholder(_), &LifetimeData::Placeholder(_))
989-
| (&LifetimeData::Placeholder(_), &LifetimeData::Empty(_))
990982
| (&LifetimeData::Placeholder(_), &LifetimeData::Erased)
991-
| (&LifetimeData::Empty(_), &LifetimeData::Static)
992-
| (&LifetimeData::Empty(_), &LifetimeData::Placeholder(_))
993-
| (&LifetimeData::Empty(_), &LifetimeData::Empty(_))
994-
| (&LifetimeData::Empty(_), &LifetimeData::Erased)
995983
| (&LifetimeData::Erased, &LifetimeData::Static)
996-
| (&LifetimeData::Erased, &LifetimeData::Placeholder(_))
997-
| (&LifetimeData::Erased, &LifetimeData::Empty(_)) => {
984+
| (&LifetimeData::Erased, &LifetimeData::Placeholder(_)) => {
998985
if a != b {
999986
self.push_lifetime_outlives_goals(variance, a.clone(), b.clone());
1000987
Ok(())

tests/test/lifetimes.rs

Lines changed: 0 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,6 @@ fn erased_lowering() {
2424
}
2525
}
2626

27-
#[test]
28-
fn empty_lowering() {
29-
lowering_success! {
30-
program {
31-
struct A<'a> where 'a: 'empty {}
32-
trait B<'a> where 'a: 'empty {}
33-
fn foo(a: &'empty ());
34-
}
35-
}
36-
}
37-
3827
#[test]
3928
fn static_outlives() {
4029
test! {
@@ -63,34 +52,6 @@ fn static_outlives() {
6352
}
6453
}
6554

66-
#[test]
67-
fn empty_outlives() {
68-
test! {
69-
program {
70-
trait Foo<'a> where 'a: 'empty {}
71-
struct Bar {}
72-
73-
impl<'a> Foo<'a> for Bar where 'a: 'empty {}
74-
}
75-
76-
goal {
77-
exists<'a> {
78-
Bar: Foo<'a>
79-
}
80-
} yields {
81-
expect![["Unique; for<?U0> { substitution [?0 := '^0.0], lifetime constraints [InEnvironment { environment: Env([]), goal: '^0.0: '<empty> }] }"]]
82-
}
83-
84-
goal {
85-
forall<'a> {
86-
Bar: Foo<'a>
87-
}
88-
} yields {
89-
expect![["Unique; lifetime constraints [InEnvironment { environment: Env([]), goal: '!1_0: '<empty> }]"]]
90-
}
91-
}
92-
}
93-
9455
#[test]
9556
fn erased_outlives() {
9657
test! {
@@ -164,20 +125,3 @@ fn erased_impls() {
164125
}
165126
}
166127
}
167-
168-
#[test]
169-
fn empty_impls() {
170-
test! {
171-
program {
172-
struct Foo {}
173-
trait Bar {}
174-
impl<'a> Bar for &'a Foo {}
175-
}
176-
177-
goal {
178-
&'empty Foo: Bar
179-
} yields {
180-
expect![["Unique"]]
181-
}
182-
}
183-
}

0 commit comments

Comments
 (0)