syntax: ast: remove TyBox and UnBox.

This commit is contained in:
Eduard Burtescu 2014-10-01 00:59:56 +03:00
parent a99e626d07
commit d1a57e479c
18 changed files with 10 additions and 63 deletions

View File

@ -1289,7 +1289,7 @@ impl LintPass for UnnecessaryAllocation {
fn check_expr(&mut self, cx: &Context, e: &ast::Expr) { fn check_expr(&mut self, cx: &Context, e: &ast::Expr) {
match e.node { match e.node {
ast::ExprUnary(ast::UnUniq, _) | ast::ExprUnary(ast::UnBox, _) => (), ast::ExprUnary(ast::UnUniq, _) => (),
_ => return _ => return
} }

View File

@ -100,7 +100,7 @@ fn check_expr(v: &mut CheckCrateVisitor, e: &Expr) {
if v.in_const { if v.in_const {
match e.node { match e.node {
ExprUnary(UnDeref, _) => { } ExprUnary(UnDeref, _) => { }
ExprUnary(UnBox, _) | ExprUnary(UnUniq, _) => { ExprUnary(UnUniq, _) => {
span_err!(v.tcx.sess, e.span, E0010, "cannot do allocations in constant expressions"); span_err!(v.tcx.sess, e.span, E0010, "cannot do allocations in constant expressions");
return; return;
} }

View File

@ -115,10 +115,6 @@ impl<'a, 'tcx, 'v> Visitor<'v> for CheckStaticVisitor<'a, 'tcx> {
span_err!(self.tcx.sess, e.span, E0020, span_err!(self.tcx.sess, e.span, E0020,
"static items are not allowed to have mutable slices"); "static items are not allowed to have mutable slices");
}, },
ast::ExprUnary(ast::UnBox, _) => {
span_err!(self.tcx.sess, e.span, E0021,
"static items are not allowed to have managed pointers");
}
ast::ExprBox(..) | ast::ExprBox(..) |
ast::ExprUnary(ast::UnUniq, _) => { ast::ExprUnary(ast::UnUniq, _) => {
span_err!(self.tcx.sess, e.span, E0022, span_err!(self.tcx.sess, e.span, E0022,

View File

@ -421,7 +421,7 @@ fn const_expr_unadjusted(cx: &CrateContext, e: &ast::Expr,
let ty = ty::expr_ty(cx.tcx(), &**e); let ty = ty::expr_ty(cx.tcx(), &**e);
let is_float = ty::type_is_fp(ty); let is_float = ty::type_is_fp(ty);
return (match u { return (match u {
ast::UnBox | ast::UnUniq | ast::UnDeref => { ast::UnUniq | ast::UnDeref => {
let (dv, _dt) = const_deref(cx, te, ty, true); let (dv, _dt) = const_deref(cx, te, ty, true);
dv dv
} }

View File

@ -1533,9 +1533,6 @@ fn trans_unary<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
}; };
immediate_rvalue_bcx(bcx, llneg, un_ty).to_expr_datumblock() immediate_rvalue_bcx(bcx, llneg, un_ty).to_expr_datumblock()
} }
ast::UnBox => {
trans_managed_expr(bcx, un_ty, sub_expr, expr_ty(bcx, sub_expr))
}
ast::UnUniq => { ast::UnUniq => {
trans_uniq_expr(bcx, un_ty, sub_expr, expr_ty(bcx, sub_expr)) trans_uniq_expr(bcx, un_ty, sub_expr, expr_ty(bcx, sub_expr))
} }

View File

@ -856,10 +856,6 @@ pub fn ast_ty_to_ty<'tcx, AC: AstConv<'tcx>, RS: RegionScope>(
match ast_ty.node { match ast_ty.node {
ast::TyNil => ty::mk_nil(), ast::TyNil => ty::mk_nil(),
ast::TyBot => ty::mk_bot(), ast::TyBot => ty::mk_bot(),
ast::TyBox(ref ty) => {
mk_pointer(this, rscope, ast::MutImmutable, &**ty, Box,
|ty| ty::mk_box(tcx, ty))
}
ast::TyUniq(ref ty) => { ast::TyUniq(ref ty) => {
mk_pointer(this, rscope, ast::MutImmutable, &**ty, Uniq, mk_pointer(this, rscope, ast::MutImmutable, &**ty, Uniq,
|ty| ty::mk_uniq(tcx, ty)) |ty| ty::mk_uniq(tcx, ty))

View File

@ -3881,8 +3881,8 @@ fn check_expr_with_unifier(fcx: &FnCtxt,
ast::ExprUnary(unop, ref oprnd) => { ast::ExprUnary(unop, ref oprnd) => {
let expected_inner = expected.map(fcx, |sty| { let expected_inner = expected.map(fcx, |sty| {
match unop { match unop {
ast::UnBox | ast::UnUniq => match *sty { ast::UnUniq => match *sty {
ty::ty_box(ty) | ty::ty_uniq(ty) => { ty::ty_uniq(ty) => {
ExpectHasType(ty) ExpectHasType(ty)
} }
_ => { _ => {
@ -3907,11 +3907,6 @@ fn check_expr_with_unifier(fcx: &FnCtxt,
if !ty::type_is_error(oprnd_t) { if !ty::type_is_error(oprnd_t) {
match unop { match unop {
ast::UnBox => {
if !ty::type_is_bot(oprnd_t) {
oprnd_t = ty::mk_box(tcx, oprnd_t)
}
}
ast::UnUniq => { ast::UnUniq => {
if !ty::type_is_bot(oprnd_t) { if !ty::type_is_bot(oprnd_t) {
oprnd_t = ty::mk_uniq(tcx, oprnd_t); oprnd_t = ty::mk_uniq(tcx, oprnd_t);

View File

@ -663,14 +663,6 @@ fn visit_expr(rcx: &mut Rcx, expr: &ast::Expr) {
visit::walk_expr(rcx, expr); visit::walk_expr(rcx, expr);
} }
ast::ExprUnary(ast::UnBox, ref base) => {
// Managed data must not have borrowed pointers within it:
let base_ty = rcx.resolve_node_type(base.id);
type_must_outlive(rcx, infer::Managed(expr.span),
base_ty, ty::ReStatic);
visit::walk_expr(rcx, expr);
}
ast::ExprUnary(ast::UnDeref, ref base) => { ast::ExprUnary(ast::UnDeref, ref base) => {
// For *a, the lifetime of a must enclose the deref // For *a, the lifetime of a must enclose the deref
let method_call = MethodCall::expr(expr.id); let method_call = MethodCall::expr(expr.id);

View File

@ -1285,7 +1285,6 @@ impl<'a, 'tcx> Rebuilder<'a, 'tcx> {
ast::TyPtr(ref mut_ty) => { ast::TyPtr(ref mut_ty) => {
ty_queue.push(&*mut_ty.ty); ty_queue.push(&*mut_ty.ty);
} }
ast::TyBox(ref ty) |
ast::TyVec(ref ty) | ast::TyVec(ref ty) |
ast::TyUniq(ref ty) | ast::TyUniq(ref ty) |
ast::TyFixedLengthVec(ref ty, _) => { ast::TyFixedLengthVec(ref ty, _) => {
@ -1323,7 +1322,6 @@ impl<'a, 'tcx> Rebuilder<'a, 'tcx> {
ty: build_to(mut_ty.ty, to), ty: build_to(mut_ty.ty, to),
}) })
} }
ast::TyBox(ty) => ast::TyBox(build_to(ty, to)),
ast::TyVec(ty) => ast::TyVec(build_to(ty, to)), ast::TyVec(ty) => ast::TyVec(build_to(ty, to)),
ast::TyUniq(ty) => ast::TyUniq(build_to(ty, to)), ast::TyUniq(ty) => ast::TyUniq(build_to(ty, to)),
ast::TyFixedLengthVec(ty, e) => { ast::TyFixedLengthVec(ty, e) => {

View File

@ -1215,7 +1215,6 @@ impl Clean<Type> for ast::Ty {
TyRptr(ref l, ref m) => TyRptr(ref l, ref m) =>
BorrowedRef {lifetime: l.clean(cx), mutability: m.mutbl.clean(cx), BorrowedRef {lifetime: l.clean(cx), mutability: m.mutbl.clean(cx),
type_: box m.ty.clean(cx)}, type_: box m.ty.clean(cx)},
TyBox(ref ty) => Managed(box ty.clean(cx)),
TyUniq(ref ty) => Unique(box ty.clean(cx)), TyUniq(ref ty) => Unique(box ty.clean(cx)),
TyVec(ref ty) => Vector(box ty.clean(cx)), TyVec(ref ty) => Vector(box ty.clean(cx)),
TyFixedLengthVec(ref ty, ref e) => FixedVector(box ty.clean(cx), TyFixedLengthVec(ref ty, ref e) => FixedVector(box ty.clean(cx),

View File

@ -416,7 +416,6 @@ pub enum BinOp {
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)] #[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)]
pub enum UnOp { pub enum UnOp {
UnBox,
UnUniq, UnUniq,
UnDeref, UnDeref,
UnNot, UnNot,
@ -953,7 +952,6 @@ pub struct UnboxedFnTy {
pub enum Ty_ { pub enum Ty_ {
TyNil, TyNil,
TyBot, /* bottom type */ TyBot, /* bottom type */
TyBox(P<Ty>),
TyUniq(P<Ty>), TyUniq(P<Ty>),
TyVec(P<Ty>), TyVec(P<Ty>),
TyFixedLengthVec(P<Ty>, P<Expr>), TyFixedLengthVec(P<Ty>, P<Expr>),

View File

@ -90,7 +90,6 @@ pub fn is_shift_binop(b: BinOp) -> bool {
pub fn unop_to_string(op: UnOp) -> &'static str { pub fn unop_to_string(op: UnOp) -> &'static str {
match op { match op {
UnBox => "box(GC) ",
UnUniq => "box() ", UnUniq => "box() ",
UnDeref => "*", UnDeref => "*",
UnNot => "!", UnNot => "!",

View File

@ -112,7 +112,6 @@ pub trait AstBuilder {
fn expr_deref(&self, sp: Span, e: P<ast::Expr>) -> P<ast::Expr>; fn expr_deref(&self, sp: Span, e: P<ast::Expr>) -> P<ast::Expr>;
fn expr_unary(&self, sp: Span, op: ast::UnOp, e: P<ast::Expr>) -> P<ast::Expr>; fn expr_unary(&self, sp: Span, op: ast::UnOp, e: P<ast::Expr>) -> P<ast::Expr>;
fn expr_managed(&self, sp: Span, e: P<ast::Expr>) -> P<ast::Expr>;
fn expr_addr_of(&self, sp: Span, e: P<ast::Expr>) -> P<ast::Expr>; fn expr_addr_of(&self, sp: Span, e: P<ast::Expr>) -> P<ast::Expr>;
fn expr_mut_addr_of(&self, sp: Span, e: P<ast::Expr>) -> P<ast::Expr>; fn expr_mut_addr_of(&self, sp: Span, e: P<ast::Expr>) -> P<ast::Expr>;
fn expr_field_access(&self, span: Span, expr: P<ast::Expr>, ident: ast::Ident) -> P<ast::Expr>; fn expr_field_access(&self, span: Span, expr: P<ast::Expr>, ident: ast::Ident) -> P<ast::Expr>;
@ -565,10 +564,6 @@ impl<'a> AstBuilder for ExtCtxt<'a> {
self.expr(sp, ast::ExprUnary(op, e)) self.expr(sp, ast::ExprUnary(op, e))
} }
fn expr_managed(&self, sp: Span, e: P<ast::Expr>) -> P<ast::Expr> {
self.expr_unary(sp, ast::UnBox, e)
}
fn expr_field_access(&self, sp: Span, expr: P<ast::Expr>, ident: ast::Ident) -> P<ast::Expr> { fn expr_field_access(&self, sp: Span, expr: P<ast::Expr>, ident: ast::Ident) -> P<ast::Expr> {
let field_name = token::get_ident(ident); let field_name = token::get_ident(ident);
let field_span = Span { let field_span = Span {

View File

@ -136,14 +136,6 @@ impl<'a> Context<'a> {
} }
} }
fn gate_box(&self, span: Span) {
self.gate_feature("managed_boxes", span,
"The managed box syntax is being replaced by the \
`std::gc::Gc` and `std::rc::Rc` types. Equivalent \
functionality to managed trait objects will be \
implemented but is currently missing.");
}
fn has_feature(&self, feature: &str) -> bool { fn has_feature(&self, feature: &str) -> bool {
self.features.iter().any(|n| n.as_slice() == feature) self.features.iter().any(|n| n.as_slice() == feature)
} }
@ -331,7 +323,6 @@ impl<'a, 'v> Visitor<'v> for Context<'a> {
experimental and likely to be removed"); experimental and likely to be removed");
}, },
ast::TyBox(_) => { self.gate_box(t.span); }
ast::TyUnboxedFn(..) => { ast::TyUnboxedFn(..) => {
self.gate_feature("unboxed_closure_sugar", self.gate_feature("unboxed_closure_sugar",
t.span, t.span,
@ -345,9 +336,6 @@ impl<'a, 'v> Visitor<'v> for Context<'a> {
fn visit_expr(&mut self, e: &ast::Expr) { fn visit_expr(&mut self, e: &ast::Expr) {
match e.node { match e.node {
ast::ExprUnary(ast::UnBox, _) => {
self.gate_box(e.span);
}
ast::ExprUnboxedFn(..) => { ast::ExprUnboxedFn(..) => {
self.gate_feature("unboxed_closures", self.gate_feature("unboxed_closures",
e.span, e.span,

View File

@ -372,7 +372,6 @@ pub fn noop_fold_ty<T: Folder>(t: P<Ty>, fld: &mut T) -> P<Ty> {
id: fld.new_id(id), id: fld.new_id(id),
node: match node { node: match node {
TyNil | TyBot | TyInfer => node, TyNil | TyBot | TyInfer => node,
TyBox(ty) => TyBox(fld.fold_ty(ty)),
TyUniq(ty) => TyUniq(fld.fold_ty(ty)), TyUniq(ty) => TyUniq(fld.fold_ty(ty)),
TyVec(ty) => TyVec(fld.fold_ty(ty)), TyVec(ty) => TyVec(fld.fold_ty(ty)),
TyPtr(mt) => TyPtr(fld.fold_mt(mt)), TyPtr(mt) => TyPtr(fld.fold_mt(mt)),

View File

@ -16,8 +16,7 @@ use ast::{RegionTyParamBound, TraitTyParamBound};
use ast::{ProvidedMethod, Public, FnStyle}; use ast::{ProvidedMethod, Public, FnStyle};
use ast::{Mod, BiAdd, Arg, Arm, Attribute, BindByRef, BindByValue}; use ast::{Mod, BiAdd, Arg, Arm, Attribute, BindByRef, BindByValue};
use ast::{BiBitAnd, BiBitOr, BiBitXor, BiRem, Block}; use ast::{BiBitAnd, BiBitOr, BiBitXor, BiRem, Block};
use ast::{BlockCheckMode, UnBox}; use ast::{BlockCheckMode, CaptureByRef, CaptureByValue, CaptureClause};
use ast::{CaptureByRef, CaptureByValue, CaptureClause};
use ast::{Crate, CrateConfig, Decl, DeclItem}; use ast::{Crate, CrateConfig, Decl, DeclItem};
use ast::{DeclLocal, DefaultBlock, UnDeref, BiDiv, EMPTY_CTXT, EnumDef, ExplicitSelf}; use ast::{DeclLocal, DefaultBlock, UnDeref, BiDiv, EMPTY_CTXT, EnumDef, ExplicitSelf};
use ast::{Expr, Expr_, ExprAddrOf, ExprMatch, ExprAgain}; use ast::{Expr, Expr_, ExprAddrOf, ExprMatch, ExprAgain};
@ -50,7 +49,7 @@ use ast::{StructVariantKind, BiSub};
use ast::StrStyle; use ast::StrStyle;
use ast::{SelfExplicit, SelfRegion, SelfStatic, SelfValue}; use ast::{SelfExplicit, SelfRegion, SelfStatic, SelfValue};
use ast::{TokenTree, TraitItem, TraitRef, TTDelim, TTSeq, TTTok}; use ast::{TokenTree, TraitItem, TraitRef, TTDelim, TTSeq, TTTok};
use ast::{TTNonterminal, TupleVariantKind, Ty, Ty_, TyBot, TyBox}; use ast::{TTNonterminal, TupleVariantKind, Ty, Ty_, TyBot};
use ast::{TypeField, TyFixedLengthVec, TyClosure, TyProc, TyBareFn}; use ast::{TypeField, TyFixedLengthVec, TyClosure, TyProc, TyBareFn};
use ast::{TyTypeof, TyInfer, TypeMethod}; use ast::{TyTypeof, TyInfer, TypeMethod};
use ast::{TyNil, TyParam, TyParamBound, TyParen, TyPath, TyPtr, TyQPath}; use ast::{TyNil, TyParam, TyParamBound, TyParen, TyPath, TyPtr, TyQPath};
@ -1455,7 +1454,7 @@ impl<'a> Parser<'a> {
self.bump(); self.bump();
let span = self.last_span; let span = self.last_span;
self.obsolete(span, ObsoleteManagedType); self.obsolete(span, ObsoleteManagedType);
TyBox(self.parse_ty(plus_allowed)) TyUniq(self.parse_ty(plus_allowed))
} else if self.token == token::TILDE { } else if self.token == token::TILDE {
// OWNED POINTER // OWNED POINTER
self.bump(); self.bump();
@ -2729,7 +2728,7 @@ impl<'a> Parser<'a> {
self.obsolete(span, ObsoleteManagedExpr); self.obsolete(span, ObsoleteManagedExpr);
let e = self.parse_prefix_expr(); let e = self.parse_prefix_expr();
hi = e.span.hi; hi = e.span.hi;
ex = self.mk_unary(UnBox, e); ex = self.mk_unary(UnUniq, e);
} }
token::TILDE => { token::TILDE => {
self.bump(); self.bump();

View File

@ -546,10 +546,6 @@ impl<'a> State<'a> {
match ty.node { match ty.node {
ast::TyNil => try!(word(&mut self.s, "()")), ast::TyNil => try!(word(&mut self.s, "()")),
ast::TyBot => try!(word(&mut self.s, "!")), ast::TyBot => try!(word(&mut self.s, "!")),
ast::TyBox(ref ty) => {
try!(word(&mut self.s, "@"));
try!(self.print_type(&**ty));
}
ast::TyUniq(ref ty) => { ast::TyUniq(ref ty) => {
try!(word(&mut self.s, "~")); try!(word(&mut self.s, "~"));
try!(self.print_type(&**ty)); try!(self.print_type(&**ty));

View File

@ -326,7 +326,7 @@ pub fn skip_ty<'v, V: Visitor<'v>>(_: &mut V, _: &'v Ty) {
pub fn walk_ty<'v, V: Visitor<'v>>(visitor: &mut V, typ: &'v Ty) { pub fn walk_ty<'v, V: Visitor<'v>>(visitor: &mut V, typ: &'v Ty) {
match typ.node { match typ.node {
TyUniq(ref ty) | TyVec(ref ty) | TyBox(ref ty) | TyParen(ref ty) => { TyUniq(ref ty) | TyVec(ref ty) | TyParen(ref ty) => {
visitor.visit_ty(&**ty) visitor.visit_ty(&**ty)
} }
TyPtr(ref mutable_type) => { TyPtr(ref mutable_type) => {