Skip to content

Commit cbac44b

Browse files
committed
---
yaml --- r: 35265 b: refs/heads/master c: 430583c h: refs/heads/master i: 35263: e650357 v: v3
1 parent ca8de92 commit cbac44b

File tree

3 files changed

+24
-4
lines changed

3 files changed

+24
-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: 07f4031bb40967f9c5c0ee61b71e1d9cffd34b58
2+
refs/heads/master: 430583c8b4efdccb19e87b2f312fc22118c6685c
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: eb8fd119c65c67f3b1b8268cc7341c22d39b7b61
55
refs/heads/try: d324a424d8f84b1eb049b12cf34182bda91b0024

trunk/src/librustc/middle/typeck/infer/assignment.rs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -136,9 +136,9 @@ priv impl Assign {
136136

137137
match (a_bnd, b_bnd) {
138138
(Some(a_bnd), Some(b_bnd)) => {
139-
// check for a case where a non-region pointer (@, ~) is
140-
// being assigned to a region pointer:
141139
match (ty::get(a_bnd).sty, ty::get(b_bnd).sty) {
140+
// check for a case where a non-region pointer (@, ~) is
141+
// being assigned to a region pointer:
142142
(ty::ty_box(_), ty::ty_rptr(r_b, mt_b)) => {
143143
let nr_b = ty::mk_box(self.infcx.tcx,
144144
{ty: mt_b.ty, mutbl: m_const});
@@ -184,8 +184,16 @@ priv impl Assign {
184184
a, nr_b, m_imm, b_f.meta.region)
185185
}
186186

187+
// check for &T being assigned to *T:
188+
(ty::ty_rptr(_, ref a_t), ty::ty_ptr(ref b_t)) => {
189+
match Sub(*self).mts(*a_t, *b_t) {
190+
Ok(_) => Ok(None),
191+
Err(e) => Err(e)
192+
}
193+
}
194+
195+
// otherwise, assignment follows normal subtype rules:
187196
_ => {
188-
// otherwise, assignment follows normal subtype rules:
189197
to_ares(Sub(*self).tys(a, b))
190198
}
191199
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
fn f(x: *int) {
2+
unsafe {
3+
assert *x == 3;
4+
}
5+
}
6+
7+
fn main() {
8+
f(&3);
9+
}
10+
11+
12+

0 commit comments

Comments
 (0)