Skip to content

Commit d1a57e4

Browse files
committed
syntax: ast: remove TyBox and UnBox.
1 parent a99e626 commit d1a57e4

File tree

18 files changed

+10
-63
lines changed

18 files changed

+10
-63
lines changed

src/librustc/lint/builtin.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1289,7 +1289,7 @@ impl LintPass for UnnecessaryAllocation {
12891289

12901290
fn check_expr(&mut self, cx: &Context, e: &ast::Expr) {
12911291
match e.node {
1292-
ast::ExprUnary(ast::UnUniq, _) | ast::ExprUnary(ast::UnBox, _) => (),
1292+
ast::ExprUnary(ast::UnUniq, _) => (),
12931293
_ => return
12941294
}
12951295

src/librustc/middle/check_const.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ fn check_expr(v: &mut CheckCrateVisitor, e: &Expr) {
100100
if v.in_const {
101101
match e.node {
102102
ExprUnary(UnDeref, _) => { }
103-
ExprUnary(UnBox, _) | ExprUnary(UnUniq, _) => {
103+
ExprUnary(UnUniq, _) => {
104104
span_err!(v.tcx.sess, e.span, E0010, "cannot do allocations in constant expressions");
105105
return;
106106
}

src/librustc/middle/check_static.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -115,10 +115,6 @@ impl<'a, 'tcx, 'v> Visitor<'v> for CheckStaticVisitor<'a, 'tcx> {
115115
span_err!(self.tcx.sess, e.span, E0020,
116116
"static items are not allowed to have mutable slices");
117117
},
118-
ast::ExprUnary(ast::UnBox, _) => {
119-
span_err!(self.tcx.sess, e.span, E0021,
120-
"static items are not allowed to have managed pointers");
121-
}
122118
ast::ExprBox(..) |
123119
ast::ExprUnary(ast::UnUniq, _) => {
124120
span_err!(self.tcx.sess, e.span, E0022,

src/librustc/middle/trans/consts.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -421,7 +421,7 @@ fn const_expr_unadjusted(cx: &CrateContext, e: &ast::Expr,
421421
let ty = ty::expr_ty(cx.tcx(), &**e);
422422
let is_float = ty::type_is_fp(ty);
423423
return (match u {
424-
ast::UnBox | ast::UnUniq | ast::UnDeref => {
424+
ast::UnUniq | ast::UnDeref => {
425425
let (dv, _dt) = const_deref(cx, te, ty, true);
426426
dv
427427
}

src/librustc/middle/trans/expr.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1533,9 +1533,6 @@ fn trans_unary<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
15331533
};
15341534
immediate_rvalue_bcx(bcx, llneg, un_ty).to_expr_datumblock()
15351535
}
1536-
ast::UnBox => {
1537-
trans_managed_expr(bcx, un_ty, sub_expr, expr_ty(bcx, sub_expr))
1538-
}
15391536
ast::UnUniq => {
15401537
trans_uniq_expr(bcx, un_ty, sub_expr, expr_ty(bcx, sub_expr))
15411538
}

src/librustc/middle/typeck/astconv.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -856,10 +856,6 @@ pub fn ast_ty_to_ty<'tcx, AC: AstConv<'tcx>, RS: RegionScope>(
856856
match ast_ty.node {
857857
ast::TyNil => ty::mk_nil(),
858858
ast::TyBot => ty::mk_bot(),
859-
ast::TyBox(ref ty) => {
860-
mk_pointer(this, rscope, ast::MutImmutable, &**ty, Box,
861-
|ty| ty::mk_box(tcx, ty))
862-
}
863859
ast::TyUniq(ref ty) => {
864860
mk_pointer(this, rscope, ast::MutImmutable, &**ty, Uniq,
865861
|ty| ty::mk_uniq(tcx, ty))

src/librustc/middle/typeck/check/mod.rs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3881,8 +3881,8 @@ fn check_expr_with_unifier(fcx: &FnCtxt,
38813881
ast::ExprUnary(unop, ref oprnd) => {
38823882
let expected_inner = expected.map(fcx, |sty| {
38833883
match unop {
3884-
ast::UnBox | ast::UnUniq => match *sty {
3885-
ty::ty_box(ty) | ty::ty_uniq(ty) => {
3884+
ast::UnUniq => match *sty {
3885+
ty::ty_uniq(ty) => {
38863886
ExpectHasType(ty)
38873887
}
38883888
_ => {
@@ -3907,11 +3907,6 @@ fn check_expr_with_unifier(fcx: &FnCtxt,
39073907

39083908
if !ty::type_is_error(oprnd_t) {
39093909
match unop {
3910-
ast::UnBox => {
3911-
if !ty::type_is_bot(oprnd_t) {
3912-
oprnd_t = ty::mk_box(tcx, oprnd_t)
3913-
}
3914-
}
39153910
ast::UnUniq => {
39163911
if !ty::type_is_bot(oprnd_t) {
39173912
oprnd_t = ty::mk_uniq(tcx, oprnd_t);

src/librustc/middle/typeck/check/regionck.rs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -663,14 +663,6 @@ fn visit_expr(rcx: &mut Rcx, expr: &ast::Expr) {
663663
visit::walk_expr(rcx, expr);
664664
}
665665

666-
ast::ExprUnary(ast::UnBox, ref base) => {
667-
// Managed data must not have borrowed pointers within it:
668-
let base_ty = rcx.resolve_node_type(base.id);
669-
type_must_outlive(rcx, infer::Managed(expr.span),
670-
base_ty, ty::ReStatic);
671-
visit::walk_expr(rcx, expr);
672-
}
673-
674666
ast::ExprUnary(ast::UnDeref, ref base) => {
675667
// For *a, the lifetime of a must enclose the deref
676668
let method_call = MethodCall::expr(expr.id);

src/librustc/middle/typeck/infer/error_reporting.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1285,7 +1285,6 @@ impl<'a, 'tcx> Rebuilder<'a, 'tcx> {
12851285
ast::TyPtr(ref mut_ty) => {
12861286
ty_queue.push(&*mut_ty.ty);
12871287
}
1288-
ast::TyBox(ref ty) |
12891288
ast::TyVec(ref ty) |
12901289
ast::TyUniq(ref ty) |
12911290
ast::TyFixedLengthVec(ref ty, _) => {
@@ -1323,7 +1322,6 @@ impl<'a, 'tcx> Rebuilder<'a, 'tcx> {
13231322
ty: build_to(mut_ty.ty, to),
13241323
})
13251324
}
1326-
ast::TyBox(ty) => ast::TyBox(build_to(ty, to)),
13271325
ast::TyVec(ty) => ast::TyVec(build_to(ty, to)),
13281326
ast::TyUniq(ty) => ast::TyUniq(build_to(ty, to)),
13291327
ast::TyFixedLengthVec(ty, e) => {

src/librustdoc/clean/mod.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1215,7 +1215,6 @@ impl Clean<Type> for ast::Ty {
12151215
TyRptr(ref l, ref m) =>
12161216
BorrowedRef {lifetime: l.clean(cx), mutability: m.mutbl.clean(cx),
12171217
type_: box m.ty.clean(cx)},
1218-
TyBox(ref ty) => Managed(box ty.clean(cx)),
12191218
TyUniq(ref ty) => Unique(box ty.clean(cx)),
12201219
TyVec(ref ty) => Vector(box ty.clean(cx)),
12211220
TyFixedLengthVec(ref ty, ref e) => FixedVector(box ty.clean(cx),

src/libsyntax/ast.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -416,7 +416,6 @@ pub enum BinOp {
416416

417417
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)]
418418
pub enum UnOp {
419-
UnBox,
420419
UnUniq,
421420
UnDeref,
422421
UnNot,
@@ -953,7 +952,6 @@ pub struct UnboxedFnTy {
953952
pub enum Ty_ {
954953
TyNil,
955954
TyBot, /* bottom type */
956-
TyBox(P<Ty>),
957955
TyUniq(P<Ty>),
958956
TyVec(P<Ty>),
959957
TyFixedLengthVec(P<Ty>, P<Expr>),

src/libsyntax/ast_util.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,6 @@ pub fn is_shift_binop(b: BinOp) -> bool {
9090

9191
pub fn unop_to_string(op: UnOp) -> &'static str {
9292
match op {
93-
UnBox => "box(GC) ",
9493
UnUniq => "box() ",
9594
UnDeref => "*",
9695
UnNot => "!",

src/libsyntax/ext/build.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,6 @@ pub trait AstBuilder {
112112
fn expr_deref(&self, sp: Span, e: P<ast::Expr>) -> P<ast::Expr>;
113113
fn expr_unary(&self, sp: Span, op: ast::UnOp, e: P<ast::Expr>) -> P<ast::Expr>;
114114

115-
fn expr_managed(&self, sp: Span, e: P<ast::Expr>) -> P<ast::Expr>;
116115
fn expr_addr_of(&self, sp: Span, e: P<ast::Expr>) -> P<ast::Expr>;
117116
fn expr_mut_addr_of(&self, sp: Span, e: P<ast::Expr>) -> P<ast::Expr>;
118117
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> {
565564
self.expr(sp, ast::ExprUnary(op, e))
566565
}
567566

568-
fn expr_managed(&self, sp: Span, e: P<ast::Expr>) -> P<ast::Expr> {
569-
self.expr_unary(sp, ast::UnBox, e)
570-
}
571-
572567
fn expr_field_access(&self, sp: Span, expr: P<ast::Expr>, ident: ast::Ident) -> P<ast::Expr> {
573568
let field_name = token::get_ident(ident);
574569
let field_span = Span {

src/libsyntax/feature_gate.rs

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -136,14 +136,6 @@ impl<'a> Context<'a> {
136136
}
137137
}
138138

139-
fn gate_box(&self, span: Span) {
140-
self.gate_feature("managed_boxes", span,
141-
"The managed box syntax is being replaced by the \
142-
`std::gc::Gc` and `std::rc::Rc` types. Equivalent \
143-
functionality to managed trait objects will be \
144-
implemented but is currently missing.");
145-
}
146-
147139
fn has_feature(&self, feature: &str) -> bool {
148140
self.features.iter().any(|n| n.as_slice() == feature)
149141
}
@@ -331,7 +323,6 @@ impl<'a, 'v> Visitor<'v> for Context<'a> {
331323
experimental and likely to be removed");
332324

333325
},
334-
ast::TyBox(_) => { self.gate_box(t.span); }
335326
ast::TyUnboxedFn(..) => {
336327
self.gate_feature("unboxed_closure_sugar",
337328
t.span,
@@ -345,9 +336,6 @@ impl<'a, 'v> Visitor<'v> for Context<'a> {
345336

346337
fn visit_expr(&mut self, e: &ast::Expr) {
347338
match e.node {
348-
ast::ExprUnary(ast::UnBox, _) => {
349-
self.gate_box(e.span);
350-
}
351339
ast::ExprUnboxedFn(..) => {
352340
self.gate_feature("unboxed_closures",
353341
e.span,

src/libsyntax/fold.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,6 @@ pub fn noop_fold_ty<T: Folder>(t: P<Ty>, fld: &mut T) -> P<Ty> {
372372
id: fld.new_id(id),
373373
node: match node {
374374
TyNil | TyBot | TyInfer => node,
375-
TyBox(ty) => TyBox(fld.fold_ty(ty)),
376375
TyUniq(ty) => TyUniq(fld.fold_ty(ty)),
377376
TyVec(ty) => TyVec(fld.fold_ty(ty)),
378377
TyPtr(mt) => TyPtr(fld.fold_mt(mt)),

src/libsyntax/parse/parser.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,7 @@ use ast::{RegionTyParamBound, TraitTyParamBound};
1616
use ast::{ProvidedMethod, Public, FnStyle};
1717
use ast::{Mod, BiAdd, Arg, Arm, Attribute, BindByRef, BindByValue};
1818
use ast::{BiBitAnd, BiBitOr, BiBitXor, BiRem, Block};
19-
use ast::{BlockCheckMode, UnBox};
20-
use ast::{CaptureByRef, CaptureByValue, CaptureClause};
19+
use ast::{BlockCheckMode, CaptureByRef, CaptureByValue, CaptureClause};
2120
use ast::{Crate, CrateConfig, Decl, DeclItem};
2221
use ast::{DeclLocal, DefaultBlock, UnDeref, BiDiv, EMPTY_CTXT, EnumDef, ExplicitSelf};
2322
use ast::{Expr, Expr_, ExprAddrOf, ExprMatch, ExprAgain};
@@ -50,7 +49,7 @@ use ast::{StructVariantKind, BiSub};
5049
use ast::StrStyle;
5150
use ast::{SelfExplicit, SelfRegion, SelfStatic, SelfValue};
5251
use ast::{TokenTree, TraitItem, TraitRef, TTDelim, TTSeq, TTTok};
53-
use ast::{TTNonterminal, TupleVariantKind, Ty, Ty_, TyBot, TyBox};
52+
use ast::{TTNonterminal, TupleVariantKind, Ty, Ty_, TyBot};
5453
use ast::{TypeField, TyFixedLengthVec, TyClosure, TyProc, TyBareFn};
5554
use ast::{TyTypeof, TyInfer, TypeMethod};
5655
use ast::{TyNil, TyParam, TyParamBound, TyParen, TyPath, TyPtr, TyQPath};
@@ -1455,7 +1454,7 @@ impl<'a> Parser<'a> {
14551454
self.bump();
14561455
let span = self.last_span;
14571456
self.obsolete(span, ObsoleteManagedType);
1458-
TyBox(self.parse_ty(plus_allowed))
1457+
TyUniq(self.parse_ty(plus_allowed))
14591458
} else if self.token == token::TILDE {
14601459
// OWNED POINTER
14611460
self.bump();
@@ -2729,7 +2728,7 @@ impl<'a> Parser<'a> {
27292728
self.obsolete(span, ObsoleteManagedExpr);
27302729
let e = self.parse_prefix_expr();
27312730
hi = e.span.hi;
2732-
ex = self.mk_unary(UnBox, e);
2731+
ex = self.mk_unary(UnUniq, e);
27332732
}
27342733
token::TILDE => {
27352734
self.bump();

src/libsyntax/print/pprust.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -546,10 +546,6 @@ impl<'a> State<'a> {
546546
match ty.node {
547547
ast::TyNil => try!(word(&mut self.s, "()")),
548548
ast::TyBot => try!(word(&mut self.s, "!")),
549-
ast::TyBox(ref ty) => {
550-
try!(word(&mut self.s, "@"));
551-
try!(self.print_type(&**ty));
552-
}
553549
ast::TyUniq(ref ty) => {
554550
try!(word(&mut self.s, "~"));
555551
try!(self.print_type(&**ty));

src/libsyntax/visit.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,7 @@ pub fn skip_ty<'v, V: Visitor<'v>>(_: &mut V, _: &'v Ty) {
326326

327327
pub fn walk_ty<'v, V: Visitor<'v>>(visitor: &mut V, typ: &'v Ty) {
328328
match typ.node {
329-
TyUniq(ref ty) | TyVec(ref ty) | TyBox(ref ty) | TyParen(ref ty) => {
329+
TyUniq(ref ty) | TyVec(ref ty) | TyParen(ref ty) => {
330330
visitor.visit_ty(&**ty)
331331
}
332332
TyPtr(ref mutable_type) => {

0 commit comments

Comments
 (0)