From 5eca7129e3857e3506d12de7591238f8a7d55da1 Mon Sep 17 00:00:00 2001 From: Patrick Walton Date: Thu, 17 Mar 2011 17:39:47 -0700 Subject: rustc: Switch mutability from being a type constructor to a field annotation --- src/comp/front/ast.rs | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) (limited to 'src/comp/front/ast.rs') diff --git a/src/comp/front/ast.rs b/src/comp/front/ast.rs index 1970f788..e519d03b 100644 --- a/src/comp/front/ast.rs +++ b/src/comp/front/ast.rs @@ -168,7 +168,6 @@ tag unop { bitnot; not; neg; - _mutable; } fn unop_to_str(unop op) -> str { @@ -178,7 +177,6 @@ fn unop_to_str(unop op) -> str { case (bitnot) {ret "~";} case (not) {ret "!";} case (neg) {ret "-";} - case (_mutable) {ret "mutable";} } } @@ -215,7 +213,7 @@ type field = rec(mutability mut, ident ident, @expr expr); type expr = spanned[expr_]; tag expr_ { - expr_vec(vec[@expr], ann); + expr_vec(vec[@expr], mutability, ann); expr_tup(vec[elt], ann); expr_rec(vec[field], option.t[@expr], ann); expr_call(@expr, vec[@expr], ann); @@ -263,7 +261,8 @@ tag lit_ { // NB: If you change this, you'll probably want to change the corresponding // type structure in middle/ty.rs as well. -type ty_field = rec(ident ident, @ty ty); +type mt = rec(@ty ty, mutability mut); +type ty_field = rec(ident ident, mt mt); type ty_arg = rec(mode mode, @ty ty); // TODO: effect type ty_method = rec(proto proto, ident ident, @@ -277,16 +276,15 @@ tag ty_ { ty_machine(util.common.ty_mach); ty_char; ty_str; - ty_box(@ty); - ty_vec(@ty); + ty_box(mt); + ty_vec(mt); ty_port(@ty); ty_chan(@ty); - ty_tup(vec[@ty]); + ty_tup(vec[mt]); ty_rec(vec[ty_field]); ty_fn(proto, vec[ty_arg], @ty); // TODO: effect ty_obj(vec[ty_method]); ty_path(path, option.t[def]); - ty_mutable(@ty); ty_type; ty_constr(@ty, vec[@constr]); } -- cgit v1.2.3 From 2ef9c01ffcd160937ddccc91a6f5e9fa24f22fd4 Mon Sep 17 00:00:00 2001 From: Patrick Walton Date: Fri, 18 Mar 2011 11:49:06 -0700 Subject: rustc: Implement "mutable?". Add a test case and XFAIL it in rustboot for now. --- src/comp/front/ast.rs | 1 + 1 file changed, 1 insertion(+) (limited to 'src/comp/front/ast.rs') diff --git a/src/comp/front/ast.rs b/src/comp/front/ast.rs index e519d03b..ec93db55 100644 --- a/src/comp/front/ast.rs +++ b/src/comp/front/ast.rs @@ -91,6 +91,7 @@ tag pat_ { tag mutability { mut; imm; + maybe_mut; } tag opacity { -- cgit v1.2.3