diff options
| author | Patrick Walton <pcwalton@mimiga.net> | 2013-12-31 12:55:39 -0800 |
|---|---|---|
| committer | Patrick Walton <pcwalton@mimiga.net> | 2014-01-03 14:02:01 -0800 |
| commit | 82a09b9a04cb72088e2ec0bd66810445efba5c2e (patch) | |
| tree | 65c6cfdf535419182323133e8e524f177046e18d /src/libsyntax | |
| parent | 88281290ffdf79d1c3700935a3116fb1a22f458f (diff) | |
| download | rust-82a09b9a04cb72088e2ec0bd66810445efba5c2e.tar.gz rust-82a09b9a04cb72088e2ec0bd66810445efba5c2e.zip | |
librustc: Remove `@mut` support from the parser
Diffstat (limited to 'src/libsyntax')
| -rw-r--r-- | src/libsyntax/ast.rs | 5 | ||||
| -rw-r--r-- | src/libsyntax/ast_util.rs | 12 | ||||
| -rw-r--r-- | src/libsyntax/ext/build.rs | 11 | ||||
| -rw-r--r-- | src/libsyntax/ext/deriving/ty.rs | 8 | ||||
| -rw-r--r-- | src/libsyntax/fold.rs | 2 | ||||
| -rw-r--r-- | src/libsyntax/parse/parser.rs | 12 | ||||
| -rw-r--r-- | src/libsyntax/print/pprust.rs | 6 | ||||
| -rw-r--r-- | src/libsyntax/visit.rs | 4 |
8 files changed, 26 insertions, 34 deletions
diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs index 4d744f4df29..3523d63ef60 100644 --- a/src/libsyntax/ast.rs +++ b/src/libsyntax/ast.rs @@ -415,7 +415,6 @@ pub enum Vstore { pub enum ExprVstore { ExprVstoreUniq, // ~[1,2,3,4] ExprVstoreBox, // @[1,2,3,4] - ExprVstoreMutBox, // @mut [1,2,3,4] ExprVstoreSlice, // &[1,2,3,4] ExprVstoreMutSlice, // &mut [1,2,3,4] } @@ -444,7 +443,7 @@ pub enum BinOp { #[deriving(Clone, Eq, Encodable, Decodable, IterBytes)] pub enum UnOp { - UnBox(Mutability), + UnBox, UnUniq, UnDeref, UnNot, @@ -875,7 +874,7 @@ pub struct TyBareFn { pub enum ty_ { ty_nil, ty_bot, /* bottom type */ - ty_box(mt), + ty_box(P<Ty>), ty_uniq(P<Ty>), ty_vec(P<Ty>), ty_fixed_length_vec(P<Ty>, @Expr), diff --git a/src/libsyntax/ast_util.rs b/src/libsyntax/ast_util.rs index 70e4922aabf..f99fed517b1 100644 --- a/src/libsyntax/ast_util.rs +++ b/src/libsyntax/ast_util.rs @@ -137,13 +137,13 @@ pub fn is_shift_binop(b: BinOp) -> bool { } } -pub fn unop_to_str(op: UnOp) -> ~str { +pub fn unop_to_str(op: UnOp) -> &'static str { match op { - UnBox(mt) => if mt == MutMutable { ~"@mut " } else { ~"@" }, - UnUniq => ~"~", - UnDeref => ~"*", - UnNot => ~"!", - UnNeg => ~"-" + UnBox => "@", + UnUniq => "~", + UnDeref => "*", + UnNot => "!", + UnNeg => "-", } } diff --git a/src/libsyntax/ext/build.rs b/src/libsyntax/ext/build.rs index 1a3513ab81c..481472e8f0b 100644 --- a/src/libsyntax/ext/build.rs +++ b/src/libsyntax/ext/build.rs @@ -54,7 +54,7 @@ pub trait AstBuilder { lifetime: Option<ast::Lifetime>, mutbl: ast::Mutability) -> P<ast::Ty>; fn ty_uniq(&self, span: Span, ty: P<ast::Ty>) -> P<ast::Ty>; - fn ty_box(&self, span: Span, ty: P<ast::Ty>, mutbl: ast::Mutability) -> P<ast::Ty>; + fn ty_box(&self, span: Span, ty: P<ast::Ty>) -> P<ast::Ty>; fn ty_option(&self, ty: P<ast::Ty>) -> P<ast::Ty>; fn ty_infer(&self, sp: Span) -> P<ast::Ty>; @@ -311,12 +311,13 @@ impl AstBuilder for ExtCtxt { self.ty(span, ast::ty_rptr(lifetime, self.ty_mt(ty, mutbl))) } + fn ty_uniq(&self, span: Span, ty: P<ast::Ty>) -> P<ast::Ty> { self.ty(span, ast::ty_uniq(ty)) } - fn ty_box(&self, span: Span, - ty: P<ast::Ty>, mutbl: ast::Mutability) -> P<ast::Ty> { - self.ty(span, ast::ty_box(self.ty_mt(ty, mutbl))) + + fn ty_box(&self, span: Span, ty: P<ast::Ty>) -> P<ast::Ty> { + self.ty(span, ast::ty_box(ty)) } fn ty_option(&self, ty: P<ast::Ty>) -> P<ast::Ty> { @@ -494,7 +495,7 @@ impl AstBuilder for ExtCtxt { } fn expr_managed(&self, sp: Span, e: @ast::Expr) -> @ast::Expr { - self.expr_unary(sp, ast::UnBox(ast::MutImmutable), e) + self.expr_unary(sp, ast::UnBox, e) } fn expr_field_access(&self, sp: Span, expr: @ast::Expr, ident: ast::Ident) -> @ast::Expr { diff --git a/src/libsyntax/ext/deriving/ty.rs b/src/libsyntax/ext/deriving/ty.rs index 10e07520a84..89bed626c1e 100644 --- a/src/libsyntax/ext/deriving/ty.rs +++ b/src/libsyntax/ext/deriving/ty.rs @@ -24,7 +24,7 @@ use opt_vec::OptVec; /// The types of pointers pub enum PtrTy<'a> { Send, // ~ - Managed(ast::Mutability), // @[mut] + Managed, // @ Borrowed(Option<&'a str>, ast::Mutability), // &['lifetime] [mut] } @@ -138,8 +138,8 @@ impl<'a> Ty<'a> { Send => { cx.ty_uniq(span, raw_ty) } - Managed(mutbl) => { - cx.ty_box(span, raw_ty, mutbl) + Managed => { + cx.ty_box(span, raw_ty) } Borrowed(ref lt, mutbl) => { let lt = mk_lifetime(cx, span, lt); @@ -251,7 +251,7 @@ pub fn get_explicit_self(cx: &ExtCtxt, span: Span, self_ptr: &Option<PtrTy>) span, match *ptr { Send => ast::sty_uniq(ast::MutImmutable), - Managed(mutbl) => ast::sty_box(mutbl), + Managed => ast::sty_box(ast::MutImmutable), Borrowed(ref lt, mutbl) => { let lt = lt.map(|s| cx.lifetime(span, cx.ident_of(s))); ast::sty_region(lt, mutbl) diff --git a/src/libsyntax/fold.rs b/src/libsyntax/fold.rs index 4a2adc04fbd..dea30d181da 100644 --- a/src/libsyntax/fold.rs +++ b/src/libsyntax/fold.rs @@ -238,7 +238,7 @@ pub trait ast_fold { fn fold_ty(&mut self, t: P<Ty>) -> P<Ty> { let node = match t.node { ty_nil | ty_bot | ty_infer => t.node.clone(), - ty_box(ref mt) => ty_box(fold_mt(mt, self)), + ty_box(ty) => ty_box(self.fold_ty(ty)), ty_uniq(ty) => ty_uniq(self.fold_ty(ty)), ty_vec(ty) => ty_vec(self.fold_ty(ty)), ty_ptr(ref mt) => ty_ptr(fold_mt(mt, self)), diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index ca856a53116..40a2ef86e4f 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -29,8 +29,7 @@ use ast::{ExprField, ExprFnBlock, ExprIf, ExprIndex}; use ast::{ExprLit, ExprLogLevel, ExprLoop, ExprMac}; use ast::{ExprMethodCall, ExprParen, ExprPath, ExprProc, ExprRepeat}; use ast::{ExprRet, ExprSelf, ExprStruct, ExprTup, ExprUnary}; -use ast::{ExprVec, ExprVstore, ExprVstoreMutBox}; -use ast::{ExprVstoreSlice, ExprVstoreBox}; +use ast::{ExprVec, ExprVstore, ExprVstoreSlice, ExprVstoreBox}; use ast::{ExprVstoreMutSlice, ExprWhile, ExprForLoop, extern_fn, Field, fn_decl}; use ast::{ExprVstoreUniq, Onceness, Once, Many}; use ast::{foreign_item, foreign_item_static, foreign_item_fn, foreign_mod}; @@ -1300,7 +1299,7 @@ impl Parser { if sigil == OwnedSigil { ty_uniq(self.parse_ty(false)) } else { - ty_box(self.parse_mt()) + ty_box(self.parse_ty(false)) } } @@ -2300,17 +2299,14 @@ impl Parser { } token::AT => { self.bump(); - let m = self.parse_mutability(); let e = self.parse_prefix_expr(); hi = e.span.hi; // HACK: turn @[...] into a @-evec ex = match e.node { - ExprVec(..) | ExprRepeat(..) if m == MutMutable => - ExprVstore(e, ExprVstoreMutBox), ExprVec(..) | ExprLit(@codemap::Spanned { node: lit_str(..), span: _}) | - ExprRepeat(..) if m == MutImmutable => ExprVstore(e, ExprVstoreBox), - _ => self.mk_unary(UnBox(m), e) + ExprRepeat(..) => ExprVstore(e, ExprVstoreBox), + _ => self.mk_unary(UnBox, e) }; } token::TILDE => { diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs index 0d68f117460..15dfacc41f1 100644 --- a/src/libsyntax/print/pprust.rs +++ b/src/libsyntax/print/pprust.rs @@ -422,7 +422,7 @@ pub fn print_type(s: &mut ps, ty: &ast::Ty) { match ty.node { ast::ty_nil => word(&mut s.s, "()"), ast::ty_bot => word(&mut s.s, "!"), - ast::ty_box(ref mt) => { word(&mut s.s, "@"); print_mt(s, mt); } + ast::ty_box(ty) => { word(&mut s.s, "@"); print_type(s, ty); } ast::ty_uniq(ty) => { word(&mut s.s, "~"); print_type(s, ty); } ast::ty_vec(ty) => { word(&mut s.s, "["); @@ -1083,10 +1083,6 @@ pub fn print_expr_vstore(s: &mut ps, t: ast::ExprVstore) { match t { ast::ExprVstoreUniq => word(&mut s.s, "~"), ast::ExprVstoreBox => word(&mut s.s, "@"), - ast::ExprVstoreMutBox => { - word(&mut s.s, "@"); - word(&mut s.s, "mut"); - } ast::ExprVstoreSlice => word(&mut s.s, "&"), ast::ExprVstoreMutSlice => { word(&mut s.s, "&"); diff --git a/src/libsyntax/visit.rs b/src/libsyntax/visit.rs index 2e83a038c58..29567ab9442 100644 --- a/src/libsyntax/visit.rs +++ b/src/libsyntax/visit.rs @@ -302,10 +302,10 @@ pub fn skip_ty<E, V:Visitor<E>>(_: &mut V, _: &Ty, _: E) { pub fn walk_ty<E:Clone, V:Visitor<E>>(visitor: &mut V, typ: &Ty, env: E) { match typ.node { - ty_uniq(ty) | ty_vec(ty) => { + ty_uniq(ty) | ty_vec(ty) | ty_box(ty) => { visitor.visit_ty(ty, env) } - ty_box(ref mutable_type) | ty_ptr(ref mutable_type) => { + ty_ptr(ref mutable_type) => { visitor.visit_ty(mutable_type.ty, env) } ty_rptr(ref lifetime, ref mutable_type) => { |
