Skip to content

Commit ea09744

Browse files
leoyvensnikomatsakis
authored andcommitted
Universal indexing: change 1'0 to 1_0, leverage it in unify_forall_apply
1 parent c8b2882 commit ea09744

File tree

5 files changed

+19
-19
lines changed

5 files changed

+19
-19
lines changed

chalk-ir/src/debug.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ impl Debug for Lifetime {
6060
fn fmt(&self, fmt: &mut Formatter) -> Result<(), Error> {
6161
match self {
6262
Lifetime::Var(depth) => write!(fmt, "'?{}", depth),
63-
Lifetime::ForAll(UniversalIndex { ui, idx }) => write!(fmt, "'!{}'{}", ui.counter, idx),
63+
Lifetime::ForAll(UniversalIndex { ui, idx }) => write!(fmt, "'!{}_{}", ui.counter, idx),
6464
}
6565
}
6666
}

chalk-solve/src/infer/test.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,6 @@ fn lifetime_constraint_indirect() {
294294
assert_eq!(constraints.len(), 1);
295295
assert_eq!(
296296
format!("{:?}", constraints[0]),
297-
"InEnvironment { environment: Env([]), goal: \'?2 == \'!1'0 }",
297+
"InEnvironment { environment: Env([]), goal: \'?2 == \'!1_0 }",
298298
);
299299
}

chalk-solve/src/infer/unify.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -242,10 +242,10 @@ impl<'t> Unifier<'t> {
242242
}
243243

244244
fn unify_forall_apply(&mut self, ty1: &QuantifiedTy, ty2: &Ty) -> Fallible<()> {
245+
let ui = self.table.new_universe();
245246
let lifetimes1: Vec<_> = (0..ty1.num_binders)
246-
.map(|_| {
247-
let new_universe = self.table.new_universe();
248-
Lifetime::ForAll(UniversalIndex { ui: new_universe, idx: 0 }).cast()
247+
.map(|idx| {
248+
Lifetime::ForAll(UniversalIndex { ui, idx }).cast()
249249
})
250250
.collect();
251251

chalk-solve/src/solve/slg/test.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -550,7 +550,7 @@ fn basic_region_constraint_from_positive_impl() {
550550
constraints: [
551551
InEnvironment {
552552
environment: Env([]),
553-
goal: '!1'1 == '!1'0
553+
goal: '!1_1 == '!1_0
554554
}
555555
]
556556
},

chalk-solve/src/solve/test.rs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -581,7 +581,7 @@ fn normalize_gat1() {
581581
}
582582
}
583583
} yields {
584-
"Unique; substitution [?0 := Iter<'!2'0, !1>], lifetime constraints []"
584+
"Unique; substitution [?0 := Iter<'!2_0, !1>], lifetime constraints []"
585585
}
586586
}
587587
}
@@ -606,7 +606,7 @@ fn normalize_gat2() {
606606
}
607607
}
608608
} yields {
609-
"Unique; substitution [?0 := Span<'!1'0, !2>], lifetime constraints []"
609+
"Unique; substitution [?0 := Span<'!1_0, !2>], lifetime constraints []"
610610
}
611611

612612
goal {
@@ -922,7 +922,7 @@ fn region_equality() {
922922
} yields {
923923
"Unique; substitution [],
924924
lifetime constraints \
925-
[InEnvironment { environment: Env([]), goal: '!1'1 == '!1'0 }]
925+
[InEnvironment { environment: Env([]), goal: '!1_1 == '!1_0 }]
926926
"
927927
}
928928

@@ -933,7 +933,7 @@ fn region_equality() {
933933
}
934934
}
935935
} yields {
936-
"Unique; substitution [?0 := '!1'0], lifetime constraints []"
936+
"Unique; substitution [?0 := '!1_0], lifetime constraints []"
937937
}
938938
}
939939
}
@@ -966,12 +966,12 @@ fn forall_equality() {
966966
// this is because the region constraints are unsolvable.
967967
//
968968
// Note that `?0` (in universe 2) must be equal to both
969-
// `!1'0` and `!1'1`, which of course it cannot be.
969+
// `!1_0` and `!1_1`, which of course it cannot be.
970970
for<'a, 'b> Ref<'a, Ref<'b, Ref<'a, Unit>>>: Eq<
971971
for<'c, 'd> Ref<'c, Ref<'d, Ref<'d, Unit>>>>
972972
} yields {
973973
"Unique; substitution [], lifetime constraints [
974-
InEnvironment { environment: Env([]), goal: '!1'1 == '!1'0 }
974+
InEnvironment { environment: Env([]), goal: '!1_1 == '!1_0 }
975975
]"
976976
}
977977
}
@@ -1185,7 +1185,7 @@ fn normalize_under_binder() {
11851185
}
11861186
}
11871187
} yields {
1188-
"Unique; substitution [?0 := Ref<'!1'0, I32>], lifetime constraints []"
1188+
"Unique; substitution [?0 := Ref<'!1_0, I32>], lifetime constraints []"
11891189
}
11901190

11911191
goal {
@@ -1197,7 +1197,7 @@ fn normalize_under_binder() {
11971197
} yields {
11981198
"Unique; for<?U0> { \
11991199
substitution [?0 := Ref<'?0, I32>], \
1200-
lifetime constraints [InEnvironment { environment: Env([]), goal: '?0 == '!1'0 }] \
1200+
lifetime constraints [InEnvironment { environment: Env([]), goal: '?0 == '!1_0 }] \
12011201
}"
12021202
}
12031203
}
@@ -1221,7 +1221,7 @@ fn unify_quantified_lifetimes() {
12211221
} yields {
12221222
"Unique; for<?U0> { \
12231223
substitution [?0 := '?0], \
1224-
lifetime constraints [InEnvironment { environment: Env([]), goal: '?0 == '!1'0 }] \
1224+
lifetime constraints [InEnvironment { environment: Env([]), goal: '?0 == '!1_0 }] \
12251225
}"
12261226
}
12271227

@@ -1237,8 +1237,8 @@ fn unify_quantified_lifetimes() {
12371237
}
12381238
} yields {
12391239
"Unique; for<?U0> { \
1240-
substitution [?0 := '?0, ?1 := '!1'0], \
1241-
lifetime constraints [InEnvironment { environment: Env([]), goal: '?0 == '!1'0 }] \
1240+
substitution [?0 := '?0, ?1 := '!1_0], \
1241+
lifetime constraints [InEnvironment { environment: Env([]), goal: '?0 == '!1_0 }] \
12421242
}"
12431243
}
12441244
}
@@ -1263,7 +1263,7 @@ fn equality_binder() {
12631263
} yields {
12641264
"Unique; for<?U1> { \
12651265
substitution [?0 := '?0], \
1266-
lifetime constraints [InEnvironment { environment: Env([]), goal: '!2'0 == '?0 }] \
1266+
lifetime constraints [InEnvironment { environment: Env([]), goal: '!2_0 == '?0 }] \
12671267
}"
12681268
}
12691269
}
@@ -2394,7 +2394,7 @@ fn quantified_types() {
23942394
} yields {
23952395
// Lifetime constraints are unsatisfiable
23962396
"Unique; substitution [], \
2397-
lifetime constraints [InEnvironment { environment: Env([]), goal: '!2'0 == '!1'0 }]"
2397+
lifetime constraints [InEnvironment { environment: Env([]), goal: '!2_0 == '!1_0 }]"
23982398
}
23992399
}
24002400
}

0 commit comments

Comments
 (0)