From 4e3d4b36dc3a030bb5f152afbfccfd4427830dac Mon Sep 17 00:00:00 2001 From: Patrick Walton Date: Thu, 23 May 2013 19:47:38 -0700 Subject: [PATCH] libsyntax: Stop parsing mutable fields --- src/librustc/middle/const_eval.rs | 6 +----- src/libsyntax/ast.rs | 1 - src/libsyntax/ext/build.rs | 2 +- src/libsyntax/fold.rs | 1 - src/libsyntax/parse/parser.rs | 10 ++++------ src/libsyntax/print/pprust.rs | 1 - 6 files changed, 6 insertions(+), 15 deletions(-) diff --git a/src/librustc/middle/const_eval.rs b/src/librustc/middle/const_eval.rs index 49d31d240ec..448ca4ab523 100644 --- a/src/librustc/middle/const_eval.rs +++ b/src/librustc/middle/const_eval.rs @@ -118,11 +118,7 @@ pub fn classify(e: @expr, ast::expr_struct(_, ref fs, None) => { let cs = do vec::map((*fs)) |f| { - if f.node.mutbl == ast::m_imm { - classify(f.node.expr, tcx) - } else { - non_const - } + classify(f.node.expr, tcx) }; join_all(cs) } diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs index a71f0ef2064..cdd16e5d890 100644 --- a/src/libsyntax/ast.rs +++ b/src/libsyntax/ast.rs @@ -425,7 +425,6 @@ pub struct arm { #[deriving(Eq, Encodable, Decodable)] pub struct field_ { - mutbl: mutability, ident: ident, expr: @expr, } diff --git a/src/libsyntax/ext/build.rs b/src/libsyntax/ext/build.rs index 7be8742d1c2..2a3c266cfa6 100644 --- a/src/libsyntax/ext/build.rs +++ b/src/libsyntax/ext/build.rs @@ -486,7 +486,7 @@ fn expr_blk(&self, b: ast::blk) -> @ast::expr { self.expr(b.span, ast::expr_block(b)) } fn field_imm(&self, span: span, name: ident, e: @ast::expr) -> ast::field { - respan(span, ast::field_ { mutbl: ast::m_imm, ident: name, expr: e }) + respan(span, ast::field_ { ident: name, expr: e }) } fn expr_struct(&self, span: span, path: @ast::Path, fields: ~[ast::field]) -> @ast::expr { self.expr(span, ast::expr_struct(path, fields, None)) diff --git a/src/libsyntax/fold.rs b/src/libsyntax/fold.rs index 709463159c5..0d863c736ed 100644 --- a/src/libsyntax/fold.rs +++ b/src/libsyntax/fold.rs @@ -433,7 +433,6 @@ pub fn noop_fold_expr(e: &expr_, fld: @ast_fold) -> expr_ { fn fold_field_(field: field, fld: @ast_fold) -> field { spanned { node: ast::field_ { - mutbl: field.node.mutbl, ident: fld.fold_ident(field.node.ident), expr: fld.fold_expr(field.node.expr), }, diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 1af0cfab273..de93bb3712b 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -1157,11 +1157,13 @@ fn parse_mutability(&self) -> mutability { // parse ident COLON expr fn parse_field(&self) -> field { let lo = self.span.lo; - let m = self.parse_mutability(); let i = self.parse_ident(); self.expect(&token::COLON); let e = self.parse_expr(); - spanned(lo, e.span.hi, ast::field_ { mutbl: m, ident: i, expr: e }) + spanned(lo, e.span.hi, ast::field_ { + ident: i, + expr: e + }) } fn mk_expr(&self, lo: BytePos, hi: BytePos, node: expr_) -> @expr { @@ -2566,10 +2568,6 @@ fn parse_name_and_ty(&self, pr: visibility, attrs: ~[attribute]) -> @struct_field { let lo = self.span.lo; - if self.eat_keyword(keywords::Mut) { - // Do nothing, for backwards compatibility. - // XXX: Remove after snapshot. - } if !is_plain_ident(&*self.token) { self.fatal("expected ident"); } diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs index 3ecd0e6ab80..5f814cc3576 100644 --- a/src/libsyntax/print/pprust.rs +++ b/src/libsyntax/print/pprust.rs @@ -1083,7 +1083,6 @@ pub fn print_call_post(s: @ps, pub fn print_expr(s: @ps, expr: @ast::expr) { fn print_field(s: @ps, field: ast::field) { ibox(s, indent_unit); - if field.node.mutbl == ast::m_mutbl { word_nbsp(s, "mut"); } print_ident(s, field.node.ident); word_space(s, ":"); print_expr(s, field.node.expr);