Skip to content

Commit 22768bf

Browse files
committed
---
yaml --- r: 14727 b: refs/heads/try c: ddeaea2 h: refs/heads/master i: 14725: 362d51b 14723: a443333 14719: 6a5b057 v: v3
1 parent 0bd6a4d commit 22768bf

File tree

11 files changed

+98
-56
lines changed

11 files changed

+98
-56
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
refs/heads/master: 61b1875c16de39c166b0f4d54bba19f9c6777d1a
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 4a81779abd786ff22d71434c6d9a5917ea4cdfff
5-
refs/heads/try: 0722786664eaa6008e8fe6536a8c20cac0a81938
5+
refs/heads/try: ddeaea228723ffa84a17898e08727e0c55a304a1
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105

branches/try/src/rustc/metadata/astencode_gen.rs

Lines changed: 60 additions & 37 deletions
Large diffs are not rendered by default.

branches/try/src/rustc/middle/trans/base.rs

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1645,18 +1645,19 @@ fn trans_unary(bcx: block, op: ast::unop, e: @ast::expr,
16451645
translated using trans_lval(), not \
16461646
trans_unary()");
16471647
}
1648-
ast::addr_of {
1649-
// FIXME: This is wrong.
1650-
let {bcx, val, kind} = trans_temp_lval(bcx, e);
1651-
if kind != owned {
1652-
bcx.sess().span_bug(e.span,
1653-
"can't take the address of an rvalue");
1654-
}
1655-
ret store_in_dest(bcx, val, dest);
1656-
}
16571648
}
16581649
}
16591650

1651+
fn trans_addr_of(cx: block, e: @ast::expr, dest: dest) -> block {
1652+
// FIXME: This is wrong.
1653+
let {bcx, val, kind} = trans_temp_lval(cx, e);
1654+
if kind != owned {
1655+
bcx.sess().span_bug(e.span,
1656+
"can't take the address of an rvalue");
1657+
}
1658+
ret store_in_dest(bcx, val, dest);
1659+
}
1660+
16601661
fn trans_compare(cx: block, op: ast::binop, lhs: ValueRef,
16611662
_lhs_t: ty::t, rhs: ValueRef, rhs_t: ty::t) -> result {
16621663
if ty::type_is_scalar(rhs_t) {
@@ -3151,6 +3152,7 @@ fn trans_expr(bcx: block, e: @ast::expr, dest: dest) -> block {
31513152
assert op != ast::deref; // lvals are handled above
31523153
ret trans_unary(bcx, op, x, e, dest);
31533154
}
3155+
ast::expr_addr_of(_, x) { ret trans_addr_of(bcx, x, dest); }
31543156
ast::expr_fn(proto, decl, body, cap_clause) {
31553157
ret closure::trans_expr_fn(
31563158
bcx, proto, decl, body, e.span, e.id, *cap_clause, dest);
@@ -4307,8 +4309,7 @@ fn trans_const_expr(cx: crate_ctxt, e: @ast::expr) -> ValueRef {
43074309
ret alt u {
43084310
ast::box(_) |
43094311
ast::uniq(_) |
4310-
ast::deref |
4311-
ast::addr_of { cx.sess.span_bug(e.span,
4312+
ast::deref { cx.sess.span_bug(e.span,
43124313
"bad unop type in trans_const_expr"); }
43134314
ast::not { llvm::LLVMConstNot(te) }
43144315
ast::neg {

branches/try/src/rustc/middle/tstate/pre_post_conditions.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -409,6 +409,10 @@ fn find_pre_post_expr(fcx: fn_ctxt, e: @expr) {
409409
find_pre_post_expr(fcx, operand);
410410
copy_pre_post(fcx.ccx, e.id, operand);
411411
}
412+
expr_addr_of(_, operand) {
413+
find_pre_post_expr(fcx, operand);
414+
copy_pre_post(fcx.ccx, e.id, operand);
415+
}
412416
expr_cast(operand, _) {
413417
find_pre_post_expr(fcx, operand);
414418
copy_pre_post(fcx.ccx, e.id, operand);

branches/try/src/rustc/middle/tstate/states.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -587,6 +587,9 @@ fn find_pre_post_state_expr(fcx: fn_ctxt, pres: prestate, e: @expr) -> bool {
587587
expr_unary(_, operand) {
588588
ret find_pre_post_state_sub(fcx, pres, operand, e.id, none);
589589
}
590+
expr_addr_of(_, operand) {
591+
ret find_pre_post_state_sub(fcx, pres, operand, e.id, none);
592+
}
590593
expr_cast(operand, _) {
591594
ret find_pre_post_state_sub(fcx, pres, operand, e.id, none);
592595
}

branches/try/src/rustc/middle/typeck.rs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2198,14 +2198,17 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, expr: @ast::expr, unify: unifier,
21982198
oper_t = check_user_unop(fcx, "-", "unary-", expr, oper_t);
21992199
}
22002200
}
2201-
ast::addr_of {
2202-
// FIXME: This is incorrect. Infer the proper region.
2203-
let tm = { ty: oper_t, mutbl: ast::m_imm };
2204-
oper_t = ty::mk_rptr(tcx, ty::re_block(0), tm);
2205-
}
22062201
}
22072202
write_ty(tcx, id, oper_t);
22082203
}
2204+
ast::expr_addr_of(mutbl, oper) {
2205+
bot = check_expr(fcx, oper);
2206+
let oper_t = expr_ty(tcx, oper);
2207+
2208+
// FIXME: This is incorrect. Infer the proper region.
2209+
let tm = { ty: oper_t, mutbl: mutbl };
2210+
oper_t = ty::mk_rptr(tcx, ty::re_block(0), tm);
2211+
}
22092212
ast::expr_path(pth) {
22102213
let defn = lookup_def(fcx, pth.span, id);
22112214

branches/try/src/rustc/syntax/ast.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ enum binop {
159159
enum unop {
160160
box(mutability),
161161
uniq(mutability),
162-
deref, not, neg, addr_of
162+
deref, not, neg
163163
}
164164

165165
// Generally, after typeck you can get the inferred value
@@ -245,6 +245,7 @@ enum expr_ {
245245
expr_field(@expr, ident, [@ty]),
246246
expr_index(@expr, @expr),
247247
expr_path(@path),
248+
expr_addr_of(mutability, @expr),
248249
expr_fail(option<@expr>),
249250
expr_break,
250251
expr_cont,

branches/try/src/rustc/syntax/fold.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -402,6 +402,7 @@ fn noop_fold_expr(e: expr_, fld: ast_fold) -> expr_ {
402402
expr_unary(binop, ohs) { expr_unary(binop, fld.fold_expr(ohs)) }
403403
expr_lit(_) { e }
404404
expr_cast(expr, ty) { expr_cast(fld.fold_expr(expr), ty) }
405+
expr_addr_of(m, ohs) { expr_addr_of(m, fld.fold_expr(ohs)) }
405406
expr_if(cond, tr, fl) {
406407
expr_if(fld.fold_expr(cond), fld.fold_block(tr),
407408
option::map(fl, fld.fold_expr))

branches/try/src/rustc/syntax/parse/parser.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1129,9 +1129,10 @@ fn parse_prefix_expr(p: parser) -> pexpr {
11291129
}
11301130
token::AND {
11311131
p.bump();
1132+
let m = parse_mutability(p);
11321133
let e = to_expr(parse_prefix_expr(p));
11331134
hi = e.span.hi;
1134-
ex = ast::expr_unary(ast::addr_of, e);
1135+
ex = ast::expr_addr_of(m, e);
11351136
}
11361137
_ { ret parse_dot_or_call_expr(p); }
11371138
}

branches/try/src/rustc/syntax/print/pprust.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -877,6 +877,10 @@ fn print_expr(s: ps, &&expr: @ast::expr) {
877877
word(s.s, ast_util::unop_to_str(op));
878878
print_op_maybe_parens(s, expr, parse::parser::unop_prec);
879879
}
880+
ast::expr_addr_of(m, expr) {
881+
print_mutability(s, m);
882+
print_expr(s, expr);
883+
}
880884
ast::expr_lit(lit) { print_literal(s, lit); }
881885
ast::expr_cast(expr, ty) {
882886
print_op_maybe_parens(s, expr, parse::parser::as_prec);

branches/try/src/rustc/syntax/visit.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -331,6 +331,7 @@ fn visit_expr<E>(ex: @expr, e: E, v: vt<E>) {
331331
expr_unary(_, a) { v.visit_expr(a, e, v); }
332332
expr_lit(_) { }
333333
expr_cast(x, t) { v.visit_expr(x, e, v); v.visit_ty(t, e, v); }
334+
expr_addr_of(_, x) { v.visit_expr(x, e, v); }
334335
expr_if(x, b, eo) {
335336
v.visit_expr(x, e, v);
336337
v.visit_block(b, e, v);

0 commit comments

Comments
 (0)