Skip to content

Commit 7d43e8e

Browse files
committed
---
yaml --- r: 11720 b: refs/heads/master c: 0722786 h: refs/heads/master v: v3
1 parent 072567f commit 7d43e8e

File tree

4 files changed

+20
-4
lines changed

4 files changed

+20
-4
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: 0c5fdc8745cd0bc5fbf9272301d3aafa2eb8f331
2+
refs/heads/master: 0722786664eaa6008e8fe6536a8c20cac0a81938
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 4a81779abd786ff22d71434c6d9a5917ea4cdfff
55
refs/heads/try: 2898dcc5d97da9427ac367542382b6239d9c0bbf

trunk/src/rustc/middle/mutbl.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ fn expr_root(tcx: ty::ctxt, ex: @expr, autoderef: bool) ->
9595
ty::ty_uniq(mt) { is_mutbl = mt.mutbl == m_mutbl; }
9696
ty::ty_res(_, _, _) { }
9797
ty::ty_enum(_, _) { }
98-
ty::ty_ptr(mt) {
98+
ty::ty_ptr(mt) | ty::ty_rptr(_, mt) {
9999
is_mutbl = mt.mutbl == m_mutbl;
100100
ptr = true;
101101
}

trunk/src/rustc/middle/trans/base.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1646,7 +1646,13 @@ fn trans_unary(bcx: block, op: ast::unop, e: @ast::expr,
16461646
trans_unary()");
16471647
}
16481648
ast::addr_of {
1649-
bcx.sess().bug("TODO pcwalton");
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);
16501656
}
16511657
}
16521658
}
@@ -2516,7 +2522,7 @@ fn trans_lval(cx: block, e: @ast::expr) -> lval_result {
25162522
} else { T_typaram_ptr(ccx.tn) };
25172523
PointerCast(sub.bcx, sub.val, ellty)
25182524
}
2519-
ty::ty_ptr(_) | ty::ty_uniq(_) { sub.val }
2525+
ty::ty_ptr(_) | ty::ty_uniq(_) | ty::ty_rptr(_,_) { sub.val }
25202526
};
25212527
ret lval_owned(sub.bcx, val);
25222528
}

trunk/src/rustc/middle/ty.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,7 @@ enum type_err {
272272
terr_ret_style_mismatch(ast::ret_style, ast::ret_style),
273273
terr_box_mutability,
274274
terr_ptr_mutability,
275+
terr_ref_mutability,
275276
terr_vec_mutability,
276277
terr_tuple_size(uint, uint),
277278
terr_record_size(uint, uint),
@@ -570,6 +571,9 @@ fn fold_ty(cx: ctxt, fld: fold_mode, ty_0: t) -> t {
570571
ty_ptr(tm) {
571572
ty = mk_ptr(cx, {ty: fold_ty(cx, fld, tm.ty), mutbl: tm.mutbl});
572573
}
574+
ty_rptr(r, tm) {
575+
ty = mk_rptr(cx, r, {ty: fold_ty(cx, fld, tm.ty), mutbl: tm.mutbl});
576+
}
573577
ty_vec(tm) {
574578
ty = mk_vec(cx, {ty: fold_ty(cx, fld, tm.ty), mutbl: tm.mutbl});
575579
}
@@ -1940,6 +1944,11 @@ mod unify {
19401944
(ty_ptr(e_mt), ty_ptr(a_mt)) {
19411945
unify_mt(cx, e_mt, a_mt, variance, terr_ptr_mutability, mk_ptr)
19421946
}
1947+
(ty_rptr(e_region, e_mt), ty_rptr(a_region, a_mt)) {
1948+
// TODO: Unify regions. Take covariance/invariance into account.
1949+
unify_mt(cx, e_mt, a_mt, variance, terr_ref_mutability,
1950+
bind mk_rptr(_, re_block(0), _))
1951+
}
19431952
(ty_res(e_id, e_inner, e_tps), ty_res(a_id, a_inner, a_tps))
19441953
if e_id == a_id {
19451954
alt unify_step(cx, e_inner, a_inner, variance) {
@@ -2116,6 +2125,7 @@ fn type_err_to_str(err: type_err) -> str {
21162125
terr_box_mutability { ret "boxed values differ in mutability"; }
21172126
terr_vec_mutability { ret "vectors differ in mutability"; }
21182127
terr_ptr_mutability { ret "pointers differ in mutability"; }
2128+
terr_ref_mutability { ret "references differ in mutability"; }
21192129
terr_tuple_size(e_sz, a_sz) {
21202130
ret "expected a tuple with " + uint::to_str(e_sz, 10u) +
21212131
" elements but found one with " + uint::to_str(a_sz, 10u) +

0 commit comments

Comments
 (0)