Skip to content

Commit f293ea2

Browse files
committed
Remove the deprecated box(PLACE) syntax.
1 parent 07ca1ab commit f293ea2

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+117
-282
lines changed

src/liballoc/boxed.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -80,11 +80,10 @@ use core::raw::{TraitObject};
8080
/// use std::boxed::HEAP;
8181
///
8282
/// fn main() {
83-
/// let foo = box(HEAP) 5;
83+
/// let foo: Box<i32> = in HEAP { 5 };
8484
/// let foo = box 5;
8585
/// }
8686
/// ```
87-
#[lang = "exchange_heap"]
8887
#[unstable(feature = "box_heap",
8988
reason = "may be renamed; uncertain about custom allocator design",
9089
issue = "27779")]

src/librustc/middle/cfg/construct.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -344,13 +344,12 @@ impl<'a, 'tcx> CFGBuilder<'a, 'tcx> {
344344
self.straightline(expr, pred, [r, l].iter().map(|&e| &**e))
345345
}
346346

347-
hir::ExprBox(Some(ref l), ref r) |
348347
hir::ExprIndex(ref l, ref r) |
349348
hir::ExprBinary(_, ref l, ref r) => { // NB: && and || handled earlier
350349
self.straightline(expr, pred, [l, r].iter().map(|&e| &**e))
351350
}
352351

353-
hir::ExprBox(None, ref e) |
352+
hir::ExprBox(ref e) |
354353
hir::ExprAddrOf(_, ref e) |
355354
hir::ExprCast(ref e, _) |
356355
hir::ExprUnary(_, ref e) |

src/librustc/middle/check_const.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -568,8 +568,7 @@ fn check_expr<'a, 'tcx>(v: &mut CheckCrateVisitor<'a, 'tcx>,
568568
"user-defined operators are not allowed in {}s", v.msg());
569569
}
570570
}
571-
hir::ExprBox(..) |
572-
hir::ExprUnary(hir::UnUniq, _) => {
571+
hir::ExprBox(_) => {
573572
v.add_qualif(ConstQualif::NOT_CONST);
574573
if v.mode != Mode::Var {
575574
span_err!(v.tcx.sess, e.span, E0010,

src/librustc/middle/expr_use_visitor.rs

+3-14
Original file line numberDiff line numberDiff line change
@@ -280,13 +280,11 @@ impl<'d,'t,'a,'tcx> ExprUseVisitor<'d,'t,'a,'tcx> {
280280
typer: &'t infer::InferCtxt<'a, 'tcx>)
281281
-> ExprUseVisitor<'d,'t,'a,'tcx>
282282
{
283-
let result = ExprUseVisitor {
283+
ExprUseVisitor {
284284
typer: typer,
285285
mc: mc::MemCategorizationContext::new(typer),
286286
delegate: delegate,
287-
};
288-
289-
result
287+
}
290288
}
291289

292290
pub fn walk_fn(&mut self,
@@ -544,17 +542,8 @@ impl<'d,'t,'a,'tcx> ExprUseVisitor<'d,'t,'a,'tcx> {
544542
self.walk_captures(expr)
545543
}
546544

547-
hir::ExprBox(ref place, ref base) => {
548-
match *place {
549-
Some(ref place) => self.consume_expr(&**place),
550-
None => {}
551-
}
545+
hir::ExprBox(ref base) => {
552546
self.consume_expr(&**base);
553-
if place.is_some() {
554-
self.tcx().sess.span_bug(
555-
expr.span,
556-
"box with explicit place remains after expansion");
557-
}
558547
}
559548
}
560549
}

src/librustc/middle/lang_items.rs

-1
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,6 @@ lets_do_this! {
341341
EhUnwindResumeLangItem, "eh_unwind_resume", eh_unwind_resume;
342342
MSVCTryFilterLangItem, "msvc_try_filter", msvc_try_filter;
343343

344-
ExchangeHeapLangItem, "exchange_heap", exchange_heap;
345344
OwnedBoxLangItem, "owned_box", owned_box;
346345

347346
PhantomDataItem, "phantom_data", phantom_data;

src/librustc/middle/liveness.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -1147,8 +1147,7 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
11471147
}
11481148

11491149
hir::ExprIndex(ref l, ref r) |
1150-
hir::ExprBinary(_, ref l, ref r) |
1151-
hir::ExprBox(Some(ref l), ref r) => {
1150+
hir::ExprBinary(_, ref l, ref r) => {
11521151
let r_succ = self.propagate_through_expr(&**r, succ);
11531152
self.propagate_through_expr(&**l, r_succ)
11541153
}
@@ -1158,7 +1157,7 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
11581157
e1.as_ref().map_or(succ, |e| self.propagate_through_expr(&**e, succ))
11591158
}
11601159

1161-
hir::ExprBox(None, ref e) |
1160+
hir::ExprBox(ref e) |
11621161
hir::ExprAddrOf(_, ref e) |
11631162
hir::ExprCast(ref e, _) |
11641163
hir::ExprUnary(_, ref e) => {

src/librustc/middle/region.rs

-3
Original file line numberDiff line numberDiff line change
@@ -994,9 +994,6 @@ fn resolve_local(visitor: &mut RegionResolutionVisitor, local: &hir::Local) {
994994
visitor, &**subexpr, blk_id);
995995
}
996996
}
997-
hir::ExprUnary(hir::UnUniq, ref subexpr) => {
998-
record_rvalue_scope_if_borrow_expr(visitor, &**subexpr, blk_id);
999-
}
1000997
hir::ExprCast(ref subexpr, _) => {
1001998
record_rvalue_scope_if_borrow_expr(visitor, &**subexpr, blk_id)
1002999
}

src/librustc_front/fold.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1040,8 +1040,8 @@ pub fn noop_fold_expr<T: Folder>(Expr {id, node, span}: Expr, folder: &mut T) ->
10401040
Expr {
10411041
id: folder.new_id(id),
10421042
node: match node {
1043-
ExprBox(p, e) => {
1044-
ExprBox(p.map(|e|folder.fold_expr(e)), folder.fold_expr(e))
1043+
ExprBox(e) => {
1044+
ExprBox(folder.fold_expr(e))
10451045
}
10461046
ExprVec(exprs) => {
10471047
ExprVec(exprs.move_map(|x| folder.fold_expr(x)))

src/librustc_front/hir.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -491,8 +491,6 @@ pub type BinOp = Spanned<BinOp_>;
491491

492492
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug, Copy)]
493493
pub enum UnOp {
494-
/// The `box` operator
495-
UnUniq,
496494
/// The `*` operator for dereferencing
497495
UnDeref,
498496
/// The `!` operator for logical inversion
@@ -595,8 +593,8 @@ impl fmt::Debug for Expr {
595593

596594
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
597595
pub enum Expr_ {
598-
/// First expr is the place; second expr is the value.
599-
ExprBox(Option<P<Expr>>, P<Expr>),
596+
/// A `box x` expression.
597+
ExprBox(P<Expr>),
600598
/// An array (`[a, b, c, d]`)
601599
ExprVec(Vec<P<Expr>>),
602600
/// A function call

src/librustc_front/lowering.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -605,7 +605,6 @@ pub fn lower_constness(c: Constness) -> hir::Constness {
605605

606606
pub fn lower_unop(u: UnOp) -> hir::UnOp {
607607
match u {
608-
UnUniq => hir::UnUniq,
609608
UnDeref => hir::UnDeref,
610609
UnNot => hir::UnNot,
611610
UnNeg => hir::UnNeg,
@@ -694,8 +693,8 @@ pub fn lower_expr(e: &Expr) -> P<hir::Expr> {
694693
P(hir::Expr {
695694
id: e.id,
696695
node: match e.node {
697-
ExprBox(ref p, ref e) => {
698-
hir::ExprBox(p.as_ref().map(|e| lower_expr(e)), lower_expr(e))
696+
ExprBox(ref e) => {
697+
hir::ExprBox(lower_expr(e))
699698
}
700699
ExprVec(ref exprs) => {
701700
hir::ExprVec(exprs.iter().map(|x| lower_expr(x)).collect())
@@ -818,6 +817,7 @@ pub fn lower_expr(e: &Expr) -> P<hir::Expr> {
818817
ExprParen(ref ex) => {
819818
return lower_expr(ex);
820819
}
820+
ExprInPlace(..) |
821821
ExprIfLet(..) |
822822
ExprWhileLet(..) |
823823
ExprForLoop(..) |

src/librustc_front/print/pprust.rs

+3-12
Original file line numberDiff line numberDiff line change
@@ -1182,16 +1182,6 @@ impl<'a> State<'a> {
11821182
Ok(())
11831183
}
11841184

1185-
fn print_expr_box(&mut self,
1186-
place: &Option<P<hir::Expr>>,
1187-
expr: &hir::Expr) -> io::Result<()> {
1188-
try!(word(&mut self.s, "box"));
1189-
try!(word(&mut self.s, "("));
1190-
try!(place.as_ref().map_or(Ok(()), |e|self.print_expr(&**e)));
1191-
try!(self.word_space(")"));
1192-
self.print_expr(expr)
1193-
}
1194-
11951185
fn print_expr_vec(&mut self, exprs: &[P<hir::Expr>]) -> io::Result<()> {
11961186
try!(self.ibox(indent_unit));
11971187
try!(word(&mut self.s, "["));
@@ -1311,8 +1301,9 @@ impl<'a> State<'a> {
13111301
try!(self.ibox(indent_unit));
13121302
try!(self.ann.pre(self, NodeExpr(expr)));
13131303
match expr.node {
1314-
hir::ExprBox(ref place, ref expr) => {
1315-
try!(self.print_expr_box(place, &**expr));
1304+
hir::ExprBox(ref expr) => {
1305+
try!(self.word_space("box"));
1306+
try!(self.print_expr(expr));
13161307
}
13171308
hir::ExprVec(ref exprs) => {
13181309
try!(self.print_expr_vec(&exprs[..]));

src/librustc_front/util.rs

+3-4
Original file line numberDiff line numberDiff line change
@@ -128,10 +128,9 @@ pub fn is_by_value_unop(u: UnOp) -> bool {
128128

129129
pub fn unop_to_string(op: UnOp) -> &'static str {
130130
match op {
131-
UnUniq => "box() ",
132-
UnDeref => "*",
133-
UnNot => "!",
134-
UnNeg => "-",
131+
UnDeref => "*",
132+
UnNot => "!",
133+
UnNeg => "-",
135134
}
136135
}
137136

src/librustc_front/visit.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -722,8 +722,7 @@ pub fn walk_exprs<'v, V: Visitor<'v>>(visitor: &mut V, expressions: &'v [P<Expr>
722722

723723
pub fn walk_expr<'v, V: Visitor<'v>>(visitor: &mut V, expression: &'v Expr) {
724724
match expression.node {
725-
ExprBox(ref place, ref subexpression) => {
726-
place.as_ref().map(|e|visitor.visit_expr(&**e));
725+
ExprBox(ref subexpression) => {
727726
visitor.visit_expr(&**subexpression)
728727
}
729728
ExprVec(ref subexpressions) => {

src/librustc_lint/unused.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -442,7 +442,7 @@ impl LintPass for UnusedAllocation {
442442
impl LateLintPass for UnusedAllocation {
443443
fn check_expr(&mut self, cx: &LateContext, e: &hir::Expr) {
444444
match e.node {
445-
hir::ExprUnary(hir::UnUniq, _) => (),
445+
hir::ExprBox(_) => {}
446446
_ => return
447447
}
448448

src/librustc_mir/build/expr/as_rvalue.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ impl<H:Hair> Builder<H> {
6767
let arg = unpack!(block = this.as_operand(block, arg));
6868
block.and(Rvalue::UnaryOp(op, arg))
6969
}
70-
ExprKind::Box { place: _, value } => {
70+
ExprKind::Box { value } => {
7171
let value = this.hir.mirror(value);
7272
let value_ty = value.ty.clone();
7373
let result = this.temp(value_ty.clone());

src/librustc_mir/hair.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ pub struct Expr<H:Hair> {
171171
#[derive(Clone, Debug)]
172172
pub enum ExprKind<H:Hair> {
173173
Scope { extent: H::CodeExtent, value: ExprRef<H> },
174-
Box { place: Option<ExprRef<H>>, value: ExprRef<H> },
174+
Box { value: ExprRef<H> },
175175
Call { fun: ExprRef<H>, args: Vec<ExprRef<H>> },
176176
Deref { arg: ExprRef<H> }, // NOT overloaded!
177177
Binary { op: BinOp, lhs: ExprRef<H>, rhs: ExprRef<H> }, // NOT overloaded!

src/librustc_mir/tcx/expr.rs

+4-9
Original file line numberDiff line numberDiff line change
@@ -140,11 +140,6 @@ impl<'a,'tcx:'a> Mirror<Cx<'a,'tcx>> for &'tcx hir::Expr {
140140
}
141141
}
142142

143-
hir::ExprUnary(hir::UnOp::UnUniq, ref arg) => {
144-
assert!(!cx.tcx.is_method_call(self.id));
145-
ExprKind::Box { place: None, value: arg.to_ref() }
146-
}
147-
148143
hir::ExprUnary(op, ref arg) => {
149144
if cx.tcx.is_method_call(self.id) {
150145
overloaded_operator(cx, self, ty::MethodCall::expr(self.id),
@@ -154,10 +149,10 @@ impl<'a,'tcx:'a> Mirror<Cx<'a,'tcx>> for &'tcx hir::Expr {
154149
let op = match op {
155150
hir::UnOp::UnNot => UnOp::Not,
156151
hir::UnOp::UnNeg => UnOp::Neg,
157-
hir::UnOp::UnUniq | hir::UnOp::UnDeref => {
152+
hir::UnOp::UnDeref => {
158153
cx.tcx.sess.span_bug(
159154
self.span,
160-
&format!("operator should have been handled elsewhere {:?}", op));
155+
"UnDeref should have been handled elsewhere");
161156
}
162157
};
163158
ExprKind::Unary { op: op, arg: arg.to_ref() }
@@ -296,8 +291,8 @@ impl<'a,'tcx:'a> Mirror<Cx<'a,'tcx>> for &'tcx hir::Expr {
296291
name: Field::Indexed(ident.node) },
297292
hir::ExprCast(ref source, _) =>
298293
ExprKind::Cast { source: source.to_ref() },
299-
hir::ExprBox(ref place, ref value) =>
300-
ExprKind::Box { place: place.to_ref(), value: value.to_ref() },
294+
hir::ExprBox(ref value) =>
295+
ExprKind::Box { value: value.to_ref() },
301296
hir::ExprVec(ref fields) =>
302297
ExprKind::Vec { fields: fields.to_ref() },
303298
hir::ExprTup(ref fields) =>

src/librustc_trans/trans/consts.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -564,10 +564,10 @@ fn const_expr_unadjusted<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
564564

565565
let is_float = ty.is_fp();
566566
unsafe { match u {
567-
hir::UnUniq | hir::UnDeref => const_deref(cx, te, ty).0,
568-
hir::UnNot => llvm::LLVMConstNot(te),
569-
hir::UnNeg if is_float => llvm::LLVMConstFNeg(te),
570-
hir::UnNeg => llvm::LLVMConstNeg(te),
567+
hir::UnDeref => const_deref(cx, te, ty).0,
568+
hir::UnNot => llvm::LLVMConstNot(te),
569+
hir::UnNeg if is_float => llvm::LLVMConstFNeg(te),
570+
hir::UnNeg => llvm::LLVMConstNeg(te),
571571
} }
572572
},
573573
hir::ExprField(ref base, field) => {

src/librustc_trans/trans/debuginfo/create_scope_map.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -325,9 +325,7 @@ fn walk_expr(cx: &CrateContext,
325325
hir::ExprTupField(ref sub_exp, _) =>
326326
walk_expr(cx, &**sub_exp, scope_stack, scope_map),
327327

328-
hir::ExprBox(ref place, ref sub_expr) => {
329-
place.as_ref().map(
330-
|e| walk_expr(cx, &**e, scope_stack, scope_map));
328+
hir::ExprBox(ref sub_expr) => {
331329
walk_expr(cx, &**sub_expr, scope_stack, scope_map);
332330
}
333331

src/librustc_trans/trans/expr.rs

+2-18
Original file line numberDiff line numberDiff line change
@@ -673,7 +673,7 @@ fn trans_datum_unadjusted<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
673673
hir::ExprIndex(ref base, ref idx) => {
674674
trans_index(bcx, expr, &**base, &**idx, MethodCall::expr(expr.id))
675675
}
676-
hir::ExprBox(_, ref contents) => {
676+
hir::ExprBox(ref contents) => {
677677
// Special case for `Box<T>`
678678
let box_ty = expr_ty(bcx, expr);
679679
let contents_ty = expr_ty(bcx, &**contents);
@@ -1649,9 +1649,6 @@ fn trans_unary<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
16491649
};
16501650
immediate_rvalue_bcx(bcx, llneg, un_ty).to_expr_datumblock()
16511651
}
1652-
hir::UnUniq => {
1653-
trans_uniq_expr(bcx, expr, un_ty, sub_expr, expr_ty(bcx, sub_expr))
1654-
}
16551652
hir::UnDeref => {
16561653
let datum = unpack_datum!(bcx, trans(bcx, sub_expr));
16571654
deref_once(bcx, expr, datum, method_call)
@@ -2769,24 +2766,11 @@ fn expr_kind(tcx: &ty::ctxt, expr: &hir::Expr) -> ExprKind {
27692766

27702767
hir::ExprLit(_) | // Note: LitStr is carved out above
27712768
hir::ExprUnary(..) |
2772-
hir::ExprBox(None, _) |
2769+
hir::ExprBox(_) |
27732770
hir::ExprAddrOf(..) |
27742771
hir::ExprBinary(..) |
27752772
hir::ExprCast(..) => {
27762773
ExprKind::RvalueDatum
27772774
}
2778-
2779-
hir::ExprBox(Some(ref place), _) => {
2780-
// Special case `Box<T>` for now:
2781-
let def_id = match tcx.def_map.borrow().get(&place.id) {
2782-
Some(def) => def.def_id(),
2783-
None => panic!("no def for place"),
2784-
};
2785-
if tcx.lang_items.exchange_heap() == Some(def_id) {
2786-
ExprKind::RvalueDatum
2787-
} else {
2788-
ExprKind::RvalueDps
2789-
}
2790-
}
27912775
}
27922776
}

0 commit comments

Comments
 (0)