Skip to content

Commit 9de288c

Browse files
committed
further refactoring away from commutativity
1 parent 4856eab commit 9de288c

File tree

1 file changed

+34
-14
lines changed

1 file changed

+34
-14
lines changed

src/rustc/middle/infer.rs

Lines changed: 34 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -961,7 +961,8 @@ iface combine {
961961
fn tag() -> str;
962962
fn bnd<V:copy>(b: bounds<V>) -> option<V>;
963963
fn with_bnd<V:copy>(b: bounds<V>, v: V) -> bounds<V>;
964-
fn c_bot(b: ty::t) -> cres<ty::t>;
964+
fn c_bot_ty(b: ty::t) -> cres<ty::t>;
965+
fn c_ty_bot(b: ty::t) -> cres<ty::t>;
965966
fn c_mts(a: ty::mt, b: ty::mt) -> cres<ty::mt>;
966967
fn c_contratys(t1: ty::t, t2: ty::t) -> cres<ty::t>;
967968
fn c_tys(t1: ty::t, t2: ty::t) -> cres<ty::t>;
@@ -974,7 +975,8 @@ iface combine {
974975
a: ty::region, b: ty::region) -> cres<ty::region>;
975976
fn c_regions(
976977
a: ty::region, b: ty::region) -> cres<ty::region>;
977-
fn c_regions_static(r: ty::region) -> cres<ty::region>;
978+
fn c_regions_static_r(r: ty::region) -> cres<ty::region>;
979+
fn c_regions_r_static(r: ty::region) -> cres<ty::region>;
978980
fn c_regions_scope_scope(
979981
a: ty::region, a_id: ast::node_id,
980982
b: ty::region, b_id: ast::node_id) -> cres<ty::region>;
@@ -1171,8 +1173,8 @@ fn c_tys<C:combine>(
11711173

11721174
indent {||
11731175
alt (ty::get(a).struct, ty::get(b).struct) {
1174-
(ty::ty_bot, _) { self.c_bot(b) }
1175-
(_, ty::ty_bot) { self.c_bot(b) }
1176+
(ty::ty_bot, _) { self.c_ty_bot(b) }
1177+
(_, ty::ty_bot) { self.c_bot_ty(b) }
11761178

11771179
(ty::ty_var(a_id), ty::ty_var(b_id)) {
11781180
c_vars(self, self.infcx().vb,
@@ -1314,8 +1316,12 @@ fn c_regions<C:combine>(
13141316

13151317
indent {||
13161318
alt (a, b) {
1317-
(ty::re_static, r) | (r, ty::re_static) {
1318-
self.c_regions_static(r)
1319+
(ty::re_static, r) {
1320+
self.c_regions_static_r(r)
1321+
}
1322+
1323+
(r, ty::re_static) {
1324+
self.c_regions_r_static(r)
13191325
}
13201326

13211327
(ty::re_var(a_id), ty::re_var(b_id)) {
@@ -1386,10 +1392,14 @@ impl of combine for lub {
13861392
{ub: some(v) with b}
13871393
}
13881394

1389-
fn c_bot(b: ty::t) -> cres<ty::t> {
1395+
fn c_bot_ty(b: ty::t) -> cres<ty::t> {
13901396
ok(b)
13911397
}
13921398

1399+
fn c_ty_bot(b: ty::t) -> cres<ty::t> {
1400+
self.c_bot_ty(b) // LUB is commutative
1401+
}
1402+
13931403
fn c_mts(a: ty::mt, b: ty::mt) -> cres<ty::mt> {
13941404
let tcx = self.infcx().tcx;
13951405

@@ -1465,12 +1475,15 @@ impl of combine for lub {
14651475
ret glb(self.infcx()).c_regions(a, b);
14661476
}
14671477

1468-
fn c_regions_static(_r: ty::region) -> cres<ty::region> {
1469-
// LUB of `r` and static is always static---what's bigger than
1470-
// that?
1478+
fn c_regions_static_r(_r: ty::region) -> cres<ty::region> {
1479+
// nothing lives longer than static
14711480
ret ok(ty::re_static);
14721481
}
14731482

1483+
fn c_regions_r_static(r: ty::region) -> cres<ty::region> {
1484+
self.c_regions_static_r(r) // LUB is commutative
1485+
}
1486+
14741487
fn c_regions_free_scope(
14751488
a: ty::region, _a_id: ast::node_id, _a_br: ty::bound_region,
14761489
_b: ty::region, _b_id: ast::node_id) -> cres<ty::region> {
@@ -1517,10 +1530,14 @@ impl of combine for glb {
15171530
{lb: some(v) with b}
15181531
}
15191532

1520-
fn c_bot(_b: ty::t) -> cres<ty::t> {
1533+
fn c_bot_ty(_b: ty::t) -> cres<ty::t> {
15211534
ok(ty::mk_bot(self.infcx().tcx))
15221535
}
15231536

1537+
fn c_ty_bot(b: ty::t) -> cres<ty::t> {
1538+
self.c_bot_ty(b) // GLB is commutative
1539+
}
1540+
15241541
fn c_mts(a: ty::mt, b: ty::mt) -> cres<ty::mt> {
15251542
let tcx = self.infcx().tcx;
15261543

@@ -1614,12 +1631,15 @@ impl of combine for glb {
16141631
ret lub(self.infcx()).c_regions(a, b);
16151632
}
16161633

1617-
fn c_regions_static(r: ty::region) -> cres<ty::region> {
1618-
// GLB of `r` and static is always `r`; static is bigger than
1619-
// everything
1634+
fn c_regions_static_r(r: ty::region) -> cres<ty::region> {
1635+
// static lives longer than everything else
16201636
ret ok(r);
16211637
}
16221638

1639+
fn c_regions_r_static(r: ty::region) -> cres<ty::region> {
1640+
self.c_regions_static_r(r) // GLB is commutative
1641+
}
1642+
16231643
fn c_regions_free_scope(
16241644
_a: ty::region, _a_id: ast::node_id, _a_br: ty::bound_region,
16251645
b: ty::region, _b_id: ast::node_id) -> cres<ty::region> {

0 commit comments

Comments
 (0)