Skip to content

Commit 16ec9aa

Browse files
committed
Support assignability for struct fields. r=pcwalton
1 parent 4557f70 commit 16ec9aa

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

src/librustc/middle/typeck/check/mod.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1679,9 +1679,11 @@ fn check_expr_with_unifier(fcx: @fn_ctxt,
16791679
let expected_field_type =
16801680
ty::lookup_field_type(
16811681
tcx, class_id, field_id, substitutions);
1682-
bot |= check_expr(fcx,
1683-
field.node.expr,
1684-
Some(expected_field_type));
1682+
bot |=
1683+
check_expr_with_assignability(
1684+
fcx,
1685+
field.node.expr,
1686+
expected_field_type);
16851687
class_field_map.insert(
16861688
field.node.ident, (field_id, true));
16871689
fields_found += 1;
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
struct Foo {
2+
x: &int
3+
}
4+
5+
fn main() {
6+
let f = Foo { x: @3 };
7+
assert *f.x == 3;
8+
}
9+

0 commit comments

Comments
 (0)