librustc: Remove @mut support from the parser
This commit is contained in:
parent
88281290ff
commit
82a09b9a04
20 changed files with 52 additions and 81 deletions
|
|
@ -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),
|
||||
|
|
|
|||
|
|
@ -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 => "-",
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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)),
|
||||
|
|
|
|||
|
|
@ -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 => {
|
||||
|
|
|
|||
|
|
@ -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, "&");
|
||||
|
|
|
|||
|
|
@ -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) => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue