Skip to content

Commit 5148131

Browse files
committed
rustc: Store the lhs and rhs of receive exprs in left to right order
With the changing of receive semantics the parser has been putting the rhs expression in the first argument of expr_recv and the lhs in the second, and all subsequent passes have been referring to them backwords (but still doing the right thing because they were assuming that lhs was the port and rhs was the receiver). This makes all code agree on what lhs and rhs mean for receive expressions.
1 parent 364cd57 commit 5148131

File tree

6 files changed

+27
-27
lines changed

6 files changed

+27
-27
lines changed

src/comp/front/parser.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1201,7 +1201,7 @@ fn parse_assign_expr(&parser p) -> @ast::expr {
12011201
p.bump();
12021202
auto rhs = parse_expr(p);
12031203
ret @spanned(lo, rhs.span.hi,
1204-
ast::expr_recv(rhs, lhs, p.get_ann()));
1204+
ast::expr_recv(lhs, rhs, p.get_ann()));
12051205
}
12061206
case (token::DARROW) {
12071207
p.bump();

src/comp/middle/trans.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6429,30 +6429,30 @@ fn trans_send(&@block_ctxt cx, &@ast::expr lhs, &@ast::expr rhs,
64296429
fn trans_recv(&@block_ctxt cx, &@ast::expr lhs, &@ast::expr rhs,
64306430
&ast::ann ann) -> result {
64316431
auto bcx = cx;
6432-
auto data = trans_lval(bcx, lhs);
6432+
auto data = trans_lval(bcx, rhs);
64336433
assert (data.is_mem);
64346434
bcx = data.res.bcx;
64356435
auto unit_ty = node_ann_type(bcx.fcx.lcx.ccx, ann);
64366436
// FIXME: calculate copy init-ness in typestate.
64376437

6438-
ret recv_val(bcx, data.res.val, rhs, unit_ty, DROP_EXISTING);
6438+
ret recv_val(bcx, data.res.val, lhs, unit_ty, DROP_EXISTING);
64396439
}
64406440

6441-
fn recv_val(&@block_ctxt cx, ValueRef lhs, &@ast::expr rhs, &ty::t unit_ty,
6441+
fn recv_val(&@block_ctxt cx, ValueRef to, &@ast::expr from, &ty::t unit_ty,
64426442
copy_action action) -> result {
64436443
auto bcx = cx;
6444-
auto prt = trans_expr(bcx, rhs);
6444+
auto prt = trans_expr(bcx, from);
64456445
bcx = prt.bcx;
6446-
auto lldataptr = bcx.build.PointerCast(lhs, T_ptr(T_ptr(T_i8())));
6446+
auto lldataptr = bcx.build.PointerCast(to, T_ptr(T_ptr(T_i8())));
64476447
auto llportptr = bcx.build.PointerCast(prt.val, T_opaque_port_ptr());
64486448
bcx.build.Call(bcx.fcx.lcx.ccx.upcalls.recv,
64496449
[bcx.fcx.lltaskptr, lldataptr, llportptr]);
6450-
auto data_load = load_if_immediate(bcx, lhs, unit_ty);
6451-
auto cp = copy_val(bcx, action, lhs, data_load, unit_ty);
6450+
auto data_load = load_if_immediate(bcx, to, unit_ty);
6451+
auto cp = copy_val(bcx, action, to, data_load, unit_ty);
64526452
bcx = cp.bcx;
64536453
// TODO: Any cleanup need to be done here?
64546454

6455-
ret res(bcx, lhs);
6455+
ret res(bcx, to);
64566456
}
64576457

64586458

src/comp/middle/tstate/pre_post_conditions.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -387,12 +387,12 @@ fn find_pre_post_expr(&fn_ctxt fcx, @expr e) {
387387
}
388388
}
389389
case (expr_recv(?lhs, ?rhs, ?a)) {
390-
alt (lhs.node) {
391-
case (expr_path(?p, ?a_lhs)) {
392-
gen_if_local(fcx, lhs, rhs, a, a_lhs, p);
390+
alt (rhs.node) {
391+
case (expr_path(?p, ?a_rhs)) {
392+
gen_if_local(fcx, rhs, lhs, a, a_rhs, p);
393393
}
394394
case (_) {
395-
// doesn't check that lhs is an lval, but
395+
// doesn't check that rhs is an lval, but
396396
// that's probably ok
397397

398398
find_pre_post_exprs(fcx, [lhs, rhs], a);

src/comp/middle/tstate/states.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -447,31 +447,31 @@ fn find_pre_post_state_expr(&fn_ctxt fcx, &prestate pres, @expr e) -> bool {
447447
}
448448
case (expr_recv(?lhs, ?rhs, ?a)) {
449449
extend_prestate_ann(fcx.ccx, a, pres);
450-
alt (lhs.node) {
451-
case (expr_path(?p, ?a_lhs)) {
450+
alt (rhs.node) {
451+
case (expr_path(?p, ?a_rhs)) {
452452
// receive to local var
453453

454-
changed = pure_exp(fcx.ccx, a_lhs, pres) || changed;
454+
changed = pure_exp(fcx.ccx, a_rhs, pres) || changed;
455455
changed =
456-
find_pre_post_state_expr(fcx, pres, rhs) || changed;
456+
find_pre_post_state_expr(fcx, pres, lhs) || changed;
457457
changed =
458458
extend_poststate_ann(fcx.ccx, a,
459-
expr_poststate(fcx.ccx, rhs)) ||
459+
expr_poststate(fcx.ccx, lhs)) ||
460460
changed;
461-
changed = gen_if_local(fcx, a_lhs, a, p) || changed;
461+
changed = gen_if_local(fcx, a_rhs, a, p) || changed;
462462
}
463463
case (_) {
464464
// receive to something that must already have been init'd
465465

466466
changed =
467-
find_pre_post_state_expr(fcx, pres, lhs) || changed;
467+
find_pre_post_state_expr(fcx, pres, rhs) || changed;
468468
changed =
469469
find_pre_post_state_expr(fcx,
470-
expr_poststate(fcx.ccx, lhs),
471-
rhs) || changed;
470+
expr_poststate(fcx.ccx, rhs),
471+
lhs) || changed;
472472
changed =
473473
extend_poststate_ann(fcx.ccx, a,
474-
expr_poststate(fcx.ccx, rhs)) ||
474+
expr_poststate(fcx.ccx, lhs)) ||
475475
changed;
476476
}
477477
}

src/comp/middle/typeck.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1705,9 +1705,9 @@ fn check_expr(&@fn_ctxt fcx, &@ast::expr expr) {
17051705
require_impure(fcx.ccx.tcx.sess, fcx.purity, expr.span);
17061706
check_expr(fcx, lhs);
17071707
check_expr(fcx, rhs);
1708-
auto item_t = expr_ty(fcx.ccx.tcx, lhs);
1708+
auto item_t = expr_ty(fcx.ccx.tcx, rhs);
17091709
auto port_t = ty::mk_port(fcx.ccx.tcx, item_t);
1710-
demand::simple(fcx, expr.span, port_t, expr_ty(fcx.ccx.tcx, rhs));
1710+
demand::simple(fcx, expr.span, port_t, expr_ty(fcx.ccx.tcx, lhs));
17111711
write::ty_only_fixup(fcx, a.id, item_t);
17121712
}
17131713
case (ast::expr_if(?cond, ?thn, ?elsopt, ?a)) {

src/comp/pretty/pprust.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -750,10 +750,10 @@ fn print_expr(&ps s, &@ast::expr expr) {
750750
print_expr(s, rhs);
751751
}
752752
case (ast::expr_recv(?lhs, ?rhs, _)) {
753-
print_expr(s, rhs);
753+
print_expr(s, lhs);
754754
space(s.s);
755755
word_space(s, "|>");
756-
print_expr(s, lhs);
756+
print_expr(s, rhs);
757757
}
758758
case (ast::expr_field(?expr, ?id, _)) {
759759
print_expr(s, expr);

0 commit comments

Comments
 (0)