librustc: Remove `@mut` support from the parser
This commit is contained in:
parent
88281290ff
commit
82a09b9a04
|
@ -189,9 +189,8 @@ impl Visitor<()> for Context {
|
|||
|
||||
fn visit_expr(&mut self, e: @ast::Expr, _: ()) {
|
||||
match e.node {
|
||||
ast::ExprUnary(_, ast::UnBox(..), _) |
|
||||
ast::ExprVstore(_, ast::ExprVstoreBox) |
|
||||
ast::ExprVstore(_, ast::ExprVstoreMutBox) => {
|
||||
ast::ExprUnary(_, ast::UnBox, _) |
|
||||
ast::ExprVstore(_, ast::ExprVstoreBox) => {
|
||||
self.gate_box(e.span);
|
||||
}
|
||||
_ => {}
|
||||
|
|
|
@ -116,7 +116,7 @@ pub fn check_expr(v: &mut CheckCrateVisitor,
|
|||
if is_const {
|
||||
match e.node {
|
||||
ExprUnary(_, UnDeref, _) => { }
|
||||
ExprUnary(_, UnBox(_), _) | ExprUnary(_, UnUniq, _) => {
|
||||
ExprUnary(_, UnBox, _) | ExprUnary(_, UnUniq, _) => {
|
||||
sess.span_err(e.span,
|
||||
"cannot do allocations in constant expressions");
|
||||
return;
|
||||
|
@ -197,8 +197,7 @@ pub fn check_expr(v: &mut CheckCrateVisitor,
|
|||
immutable values");
|
||||
},
|
||||
ExprVstore(_, ExprVstoreUniq) |
|
||||
ExprVstore(_, ExprVstoreBox) |
|
||||
ExprVstore(_, ExprVstoreMutBox) => {
|
||||
ExprVstore(_, ExprVstoreBox) => {
|
||||
sess.span_err(e.span, "cannot allocate vectors in constant expressions")
|
||||
},
|
||||
|
||||
|
|
|
@ -239,7 +239,6 @@ impl ConstEvalVisitor {
|
|||
ast::ExprVstoreSlice => self.classify(e),
|
||||
ast::ExprVstoreUniq |
|
||||
ast::ExprVstoreBox |
|
||||
ast::ExprVstoreMutBox |
|
||||
ast::ExprVstoreMutSlice => non_const
|
||||
}
|
||||
}
|
||||
|
|
|
@ -306,7 +306,7 @@ pub fn check_expr(cx: &mut Context, e: @Expr) {
|
|||
}
|
||||
|
||||
match e.node {
|
||||
ExprUnary(_, UnBox(_), interior) => {
|
||||
ExprUnary(_, UnBox, interior) => {
|
||||
let interior_type = ty::expr_ty(cx.tcx, interior);
|
||||
let _ = check_durable(cx.tcx, interior_type, interior.span);
|
||||
}
|
||||
|
|
|
@ -1068,7 +1068,7 @@ fn check_unnecessary_allocation(cx: &Context, e: &ast::Expr) {
|
|||
}
|
||||
}
|
||||
ast::ExprUnary(_, ast::UnUniq, _) |
|
||||
ast::ExprUnary(_, ast::UnBox(..), _) => BoxAllocation,
|
||||
ast::ExprUnary(_, ast::UnBox, _) => BoxAllocation,
|
||||
|
||||
_ => return
|
||||
};
|
||||
|
|
|
@ -377,9 +377,7 @@ fn const_expr_unadjusted(cx: @CrateContext,
|
|||
let ty = ty::expr_ty(cx.tcx, e);
|
||||
let is_float = ty::type_is_fp(ty);
|
||||
return (match u {
|
||||
ast::UnBox(_) |
|
||||
ast::UnUniq |
|
||||
ast::UnDeref => {
|
||||
ast::UnBox | ast::UnUniq | ast::UnDeref => {
|
||||
let (dv, _dt) = const_deref(cx, te, ty, true);
|
||||
dv
|
||||
}
|
||||
|
|
|
@ -590,8 +590,7 @@ fn trans_rvalue_datum_unadjusted(bcx: @Block, expr: &ast::Expr) -> DatumBlock {
|
|||
ast::ExprPath(_) | ast::ExprSelf => {
|
||||
return trans_def_datum_unadjusted(bcx, expr, bcx.def(expr.id));
|
||||
}
|
||||
ast::ExprVstore(contents, ast::ExprVstoreBox) |
|
||||
ast::ExprVstore(contents, ast::ExprVstoreMutBox) => {
|
||||
ast::ExprVstore(contents, ast::ExprVstoreBox) => {
|
||||
return tvec::trans_uniq_or_managed_vstore(bcx, heap_managed,
|
||||
expr, contents);
|
||||
}
|
||||
|
@ -1406,9 +1405,8 @@ fn trans_unary_datum(bcx: @Block,
|
|||
};
|
||||
immediate_rvalue_bcx(bcx, llneg, un_ty)
|
||||
}
|
||||
ast::UnBox(_) => {
|
||||
trans_boxed_expr(bcx, un_ty, sub_expr, sub_ty,
|
||||
heap_managed)
|
||||
ast::UnBox => {
|
||||
trans_boxed_expr(bcx, un_ty, sub_expr, sub_ty, heap_managed)
|
||||
}
|
||||
ast::UnUniq => {
|
||||
let heap = heap_for_unique(bcx, un_ty);
|
||||
|
|
|
@ -3257,7 +3257,6 @@ pub fn expr_kind(tcx: ctxt,
|
|||
ast::ExprAddrOf(..) |
|
||||
ast::ExprBinary(..) |
|
||||
ast::ExprVstore(_, ast::ExprVstoreBox) |
|
||||
ast::ExprVstore(_, ast::ExprVstoreMutBox) |
|
||||
ast::ExprVstore(_, ast::ExprVstoreUniq) => {
|
||||
RvalueDatumExpr
|
||||
}
|
||||
|
|
|
@ -401,8 +401,8 @@ pub fn ast_ty_to_ty<AC:AstConv, RS:RegionScope>(
|
|||
let typ = match ast_ty.node {
|
||||
ast::ty_nil => ty::mk_nil(),
|
||||
ast::ty_bot => ty::mk_bot(),
|
||||
ast::ty_box(ref mt) => {
|
||||
let mt = ast::mt { ty: mt.ty, mutbl: ast::MutImmutable };
|
||||
ast::ty_box(ty) => {
|
||||
let mt = ast::mt { ty: ty, mutbl: ast::MutImmutable };
|
||||
mk_pointer(this, rscope, &mt, ty::vstore_box,
|
||||
|tmt| ty::mk_box(tcx, tmt.ty))
|
||||
}
|
||||
|
|
|
@ -2628,15 +2628,12 @@ pub fn check_expr_with_unifier(fcx: @FnCtxt,
|
|||
}
|
||||
ast::ExprVec(ref args, mutbl) => {
|
||||
let tt = ast_expr_vstore_to_vstore(fcx, ev, vst);
|
||||
let mutability;
|
||||
let mut any_error = false;
|
||||
let mut any_bot = false;
|
||||
match vst {
|
||||
ast::ExprVstoreMutBox | ast::ExprVstoreMutSlice => {
|
||||
mutability = ast::MutMutable
|
||||
}
|
||||
_ => mutability = mutbl
|
||||
}
|
||||
let mutability = match vst {
|
||||
ast::ExprVstoreMutSlice => ast::MutMutable,
|
||||
_ => mutbl,
|
||||
};
|
||||
let t: ty::t = fcx.infcx().next_ty_var();
|
||||
for e in args.iter() {
|
||||
check_expr_has_type(fcx, *e, t);
|
||||
|
@ -2650,11 +2647,9 @@ pub fn check_expr_with_unifier(fcx: @FnCtxt,
|
|||
}
|
||||
if any_error {
|
||||
ty::mk_err()
|
||||
}
|
||||
else if any_bot {
|
||||
} else if any_bot {
|
||||
ty::mk_bot()
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
ty::mk_evec(tcx, ty::mt {ty: t, mutbl: mutability}, tt)
|
||||
}
|
||||
}
|
||||
|
@ -2663,10 +2658,8 @@ pub fn check_expr_with_unifier(fcx: @FnCtxt,
|
|||
let _ = ty::eval_repeat_count(fcx, count_expr);
|
||||
let tt = ast_expr_vstore_to_vstore(fcx, ev, vst);
|
||||
let mutability = match vst {
|
||||
ast::ExprVstoreMutBox | ast::ExprVstoreMutSlice => {
|
||||
ast::MutMutable
|
||||
}
|
||||
_ => mutbl
|
||||
ast::ExprVstoreMutSlice => ast::MutMutable,
|
||||
_ => mutbl,
|
||||
};
|
||||
let t: ty::t = fcx.infcx().next_ty_var();
|
||||
check_expr_has_type(fcx, element, t);
|
||||
|
@ -2741,7 +2734,7 @@ pub fn check_expr_with_unifier(fcx: @FnCtxt,
|
|||
ast::ExprUnary(callee_id, unop, oprnd) => {
|
||||
let exp_inner = unpack_expected(fcx, expected, |sty| {
|
||||
match unop {
|
||||
ast::UnBox(_) | ast::UnUniq => match *sty {
|
||||
ast::UnBox | ast::UnUniq => match *sty {
|
||||
ty::ty_box(ty) => Some(ty),
|
||||
ty::ty_uniq(ref mt) => Some(mt.ty),
|
||||
_ => None
|
||||
|
@ -2755,7 +2748,7 @@ pub fn check_expr_with_unifier(fcx: @FnCtxt,
|
|||
if !ty::type_is_error(oprnd_t) &&
|
||||
!ty::type_is_bot(oprnd_t) {
|
||||
match unop {
|
||||
ast::UnBox(_) => {
|
||||
ast::UnBox => {
|
||||
oprnd_t = ty::mk_box(tcx, oprnd_t)
|
||||
}
|
||||
ast::UnUniq => {
|
||||
|
@ -3920,7 +3913,7 @@ pub fn ast_expr_vstore_to_vstore(fcx: @FnCtxt,
|
|||
-> ty::vstore {
|
||||
match v {
|
||||
ast::ExprVstoreUniq => ty::vstore_uniq,
|
||||
ast::ExprVstoreBox | ast::ExprVstoreMutBox => ty::vstore_box,
|
||||
ast::ExprVstoreBox => ty::vstore_box,
|
||||
ast::ExprVstoreSlice | ast::ExprVstoreMutSlice => {
|
||||
let r = fcx.infcx().next_region_var(infer::AddrOfSlice(e.span));
|
||||
ty::vstore_slice(r)
|
||||
|
|
|
@ -594,7 +594,7 @@ pub enum Type {
|
|||
/// aka ty_bot
|
||||
Bottom,
|
||||
Unique(~Type),
|
||||
Managed(Mutability, ~Type),
|
||||
Managed(~Type),
|
||||
RawPointer(Mutability, ~Type),
|
||||
BorrowedRef { lifetime: Option<Lifetime>, mutability: Mutability, type_: ~Type},
|
||||
// region, raw, other boxes, mutable
|
||||
|
@ -620,7 +620,7 @@ impl Clean<Type> for ast::Ty {
|
|||
ty_rptr(ref l, ref m) =>
|
||||
BorrowedRef {lifetime: l.clean(), mutability: m.mutbl.clean(),
|
||||
type_: ~m.ty.clean()},
|
||||
ty_box(ref m) => Managed(m.mutbl.clean(), ~m.ty.clean()),
|
||||
ty_box(ty) => Managed(~ty.clean()),
|
||||
ty_uniq(ty) => Unique(~ty.clean()),
|
||||
ty_vec(ty) => Vector(~ty.clean()),
|
||||
ty_fixed_length_vec(ty, ref e) => FixedVector(~ty.clean(),
|
||||
|
|
|
@ -340,13 +340,7 @@ impl fmt::Default for clean::Type {
|
|||
clean::Unit => f.buf.write("()".as_bytes()),
|
||||
clean::Bottom => f.buf.write("!".as_bytes()),
|
||||
clean::Unique(ref t) => write!(f.buf, "~{}", **t),
|
||||
clean::Managed(m, ref t) => {
|
||||
write!(f.buf, "@{}{}",
|
||||
match m {
|
||||
clean::Mutable => "mut ",
|
||||
clean::Immutable => "",
|
||||
}, **t)
|
||||
}
|
||||
clean::Managed(ref t) => write!(f.buf, "@{}", **t),
|
||||
clean::RawPointer(m, ref t) => {
|
||||
write!(f.buf, "*{}{}",
|
||||
match m {
|
||||
|
|
|
@ -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…
Reference in New Issue