Support assignability for struct fields. r=pcwalton

This commit is contained in:
Niko Matsakis 2013-01-07 16:57:43 -08:00
parent 4557f70487
commit 16ec9aa6e7
2 changed files with 14 additions and 3 deletions

View File

@ -1679,9 +1679,11 @@ fn check_expr_with_unifier(fcx: @fn_ctxt,
let expected_field_type =
ty::lookup_field_type(
tcx, class_id, field_id, substitutions);
bot |= check_expr(fcx,
field.node.expr,
Some(expected_field_type));
bot |=
check_expr_with_assignability(
fcx,
field.node.expr,
expected_field_type);
class_field_map.insert(
field.node.ident, (field_id, true));
fields_found += 1;

View File

@ -0,0 +1,9 @@
struct Foo {
x: &int
}
fn main() {
let f = Foo { x: @3 };
assert *f.x == 3;
}