Skip to content

Remove the deprecated box(PLACE) syntax. #28608

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 25, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions src/liballoc/boxed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,10 @@ use core::raw::{TraitObject};
/// use std::boxed::HEAP;
///
/// fn main() {
/// let foo = box(HEAP) 5;
/// let foo: Box<i32> = in HEAP { 5 };
/// let foo = box 5;
/// }
/// ```
#[lang = "exchange_heap"]
#[unstable(feature = "box_heap",
reason = "may be renamed; uncertain about custom allocator design",
issue = "27779")]
Expand Down
3 changes: 1 addition & 2 deletions src/librustc/middle/cfg/construct.rs
Original file line number Diff line number Diff line change
Expand Up @@ -344,13 +344,12 @@ impl<'a, 'tcx> CFGBuilder<'a, 'tcx> {
self.straightline(expr, pred, [r, l].iter().map(|&e| &**e))
}

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

hir::ExprBox(None, ref e) |
hir::ExprBox(ref e) |
hir::ExprAddrOf(_, ref e) |
hir::ExprCast(ref e, _) |
hir::ExprUnary(_, ref e) |
Expand Down
3 changes: 1 addition & 2 deletions src/librustc/middle/check_const.rs
Original file line number Diff line number Diff line change
Expand Up @@ -568,8 +568,7 @@ fn check_expr<'a, 'tcx>(v: &mut CheckCrateVisitor<'a, 'tcx>,
"user-defined operators are not allowed in {}s", v.msg());
}
}
hir::ExprBox(..) |
hir::ExprUnary(hir::UnUniq, _) => {
hir::ExprBox(_) => {
v.add_qualif(ConstQualif::NOT_CONST);
if v.mode != Mode::Var {
span_err!(v.tcx.sess, e.span, E0010,
Expand Down
17 changes: 3 additions & 14 deletions src/librustc/middle/expr_use_visitor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -280,13 +280,11 @@ impl<'d,'t,'a,'tcx> ExprUseVisitor<'d,'t,'a,'tcx> {
typer: &'t infer::InferCtxt<'a, 'tcx>)
-> ExprUseVisitor<'d,'t,'a,'tcx>
{
let result = ExprUseVisitor {
ExprUseVisitor {
typer: typer,
mc: mc::MemCategorizationContext::new(typer),
delegate: delegate,
};

result
}
}

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

hir::ExprBox(ref place, ref base) => {
match *place {
Some(ref place) => self.consume_expr(&**place),
None => {}
}
hir::ExprBox(ref base) => {
self.consume_expr(&**base);
if place.is_some() {
self.tcx().sess.span_bug(
expr.span,
"box with explicit place remains after expansion");
}
}
}
}
Expand Down
1 change: 0 additions & 1 deletion src/librustc/middle/lang_items.rs
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,6 @@ lets_do_this! {
EhUnwindResumeLangItem, "eh_unwind_resume", eh_unwind_resume;
MSVCTryFilterLangItem, "msvc_try_filter", msvc_try_filter;

ExchangeHeapLangItem, "exchange_heap", exchange_heap;
OwnedBoxLangItem, "owned_box", owned_box;

PhantomDataItem, "phantom_data", phantom_data;
Expand Down
5 changes: 2 additions & 3 deletions src/librustc/middle/liveness.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1147,8 +1147,7 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
}

hir::ExprIndex(ref l, ref r) |
hir::ExprBinary(_, ref l, ref r) |
hir::ExprBox(Some(ref l), ref r) => {
hir::ExprBinary(_, ref l, ref r) => {
let r_succ = self.propagate_through_expr(&**r, succ);
self.propagate_through_expr(&**l, r_succ)
}
Expand All @@ -1158,7 +1157,7 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
e1.as_ref().map_or(succ, |e| self.propagate_through_expr(&**e, succ))
}

hir::ExprBox(None, ref e) |
hir::ExprBox(ref e) |
hir::ExprAddrOf(_, ref e) |
hir::ExprCast(ref e, _) |
hir::ExprUnary(_, ref e) => {
Expand Down
3 changes: 0 additions & 3 deletions src/librustc/middle/region.rs
Original file line number Diff line number Diff line change
Expand Up @@ -994,9 +994,6 @@ fn resolve_local(visitor: &mut RegionResolutionVisitor, local: &hir::Local) {
visitor, &**subexpr, blk_id);
}
}
hir::ExprUnary(hir::UnUniq, ref subexpr) => {
record_rvalue_scope_if_borrow_expr(visitor, &**subexpr, blk_id);
}
hir::ExprCast(ref subexpr, _) => {
record_rvalue_scope_if_borrow_expr(visitor, &**subexpr, blk_id)
}
Expand Down
4 changes: 2 additions & 2 deletions src/librustc_front/fold.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1040,8 +1040,8 @@ pub fn noop_fold_expr<T: Folder>(Expr {id, node, span}: Expr, folder: &mut T) ->
Expr {
id: folder.new_id(id),
node: match node {
ExprBox(p, e) => {
ExprBox(p.map(|e|folder.fold_expr(e)), folder.fold_expr(e))
ExprBox(e) => {
ExprBox(folder.fold_expr(e))
}
ExprVec(exprs) => {
ExprVec(exprs.move_map(|x| folder.fold_expr(x)))
Expand Down
6 changes: 2 additions & 4 deletions src/librustc_front/hir.rs
Original file line number Diff line number Diff line change
Expand Up @@ -491,8 +491,6 @@ pub type BinOp = Spanned<BinOp_>;

#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug, Copy)]
pub enum UnOp {
/// The `box` operator
UnUniq,
/// The `*` operator for dereferencing
UnDeref,
/// The `!` operator for logical inversion
Expand Down Expand Up @@ -595,8 +593,8 @@ impl fmt::Debug for Expr {

#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
pub enum Expr_ {
/// First expr is the place; second expr is the value.
ExprBox(Option<P<Expr>>, P<Expr>),
/// A `box x` expression.
ExprBox(P<Expr>),
/// An array (`[a, b, c, d]`)
ExprVec(Vec<P<Expr>>),
/// A function call
Expand Down
6 changes: 3 additions & 3 deletions src/librustc_front/lowering.rs
Original file line number Diff line number Diff line change
Expand Up @@ -605,7 +605,6 @@ pub fn lower_constness(c: Constness) -> hir::Constness {

pub fn lower_unop(u: UnOp) -> hir::UnOp {
match u {
UnUniq => hir::UnUniq,
UnDeref => hir::UnDeref,
UnNot => hir::UnNot,
UnNeg => hir::UnNeg,
Expand Down Expand Up @@ -694,8 +693,8 @@ pub fn lower_expr(e: &Expr) -> P<hir::Expr> {
P(hir::Expr {
id: e.id,
node: match e.node {
ExprBox(ref p, ref e) => {
hir::ExprBox(p.as_ref().map(|e| lower_expr(e)), lower_expr(e))
ExprBox(ref e) => {
hir::ExprBox(lower_expr(e))
}
ExprVec(ref exprs) => {
hir::ExprVec(exprs.iter().map(|x| lower_expr(x)).collect())
Expand Down Expand Up @@ -818,6 +817,7 @@ pub fn lower_expr(e: &Expr) -> P<hir::Expr> {
ExprParen(ref ex) => {
return lower_expr(ex);
}
ExprInPlace(..) |
ExprIfLet(..) |
ExprWhileLet(..) |
ExprForLoop(..) |
Expand Down
15 changes: 3 additions & 12 deletions src/librustc_front/print/pprust.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1182,16 +1182,6 @@ impl<'a> State<'a> {
Ok(())
}

fn print_expr_box(&mut self,
place: &Option<P<hir::Expr>>,
expr: &hir::Expr) -> io::Result<()> {
try!(word(&mut self.s, "box"));
try!(word(&mut self.s, "("));
try!(place.as_ref().map_or(Ok(()), |e|self.print_expr(&**e)));
try!(self.word_space(")"));
self.print_expr(expr)
}

fn print_expr_vec(&mut self, exprs: &[P<hir::Expr>]) -> io::Result<()> {
try!(self.ibox(indent_unit));
try!(word(&mut self.s, "["));
Expand Down Expand Up @@ -1311,8 +1301,9 @@ impl<'a> State<'a> {
try!(self.ibox(indent_unit));
try!(self.ann.pre(self, NodeExpr(expr)));
match expr.node {
hir::ExprBox(ref place, ref expr) => {
try!(self.print_expr_box(place, &**expr));
hir::ExprBox(ref expr) => {
try!(self.word_space("box"));
try!(self.print_expr(expr));
}
hir::ExprVec(ref exprs) => {
try!(self.print_expr_vec(&exprs[..]));
Expand Down
7 changes: 3 additions & 4 deletions src/librustc_front/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,10 +128,9 @@ pub fn is_by_value_unop(u: UnOp) -> bool {

pub fn unop_to_string(op: UnOp) -> &'static str {
match op {
UnUniq => "box() ",
UnDeref => "*",
UnNot => "!",
UnNeg => "-",
UnDeref => "*",
UnNot => "!",
UnNeg => "-",
}
}

Expand Down
3 changes: 1 addition & 2 deletions src/librustc_front/visit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -722,8 +722,7 @@ pub fn walk_exprs<'v, V: Visitor<'v>>(visitor: &mut V, expressions: &'v [P<Expr>

pub fn walk_expr<'v, V: Visitor<'v>>(visitor: &mut V, expression: &'v Expr) {
match expression.node {
ExprBox(ref place, ref subexpression) => {
place.as_ref().map(|e|visitor.visit_expr(&**e));
ExprBox(ref subexpression) => {
visitor.visit_expr(&**subexpression)
}
ExprVec(ref subexpressions) => {
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_lint/unused.rs
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,7 @@ impl LintPass for UnusedAllocation {
impl LateLintPass for UnusedAllocation {
fn check_expr(&mut self, cx: &LateContext, e: &hir::Expr) {
match e.node {
hir::ExprUnary(hir::UnUniq, _) => (),
hir::ExprBox(_) => {}
_ => return
}

Expand Down
2 changes: 1 addition & 1 deletion src/librustc_mir/build/expr/as_rvalue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ impl<H:Hair> Builder<H> {
let arg = unpack!(block = this.as_operand(block, arg));
block.and(Rvalue::UnaryOp(op, arg))
}
ExprKind::Box { place: _, value } => {
ExprKind::Box { value } => {
let value = this.hir.mirror(value);
let value_ty = value.ty.clone();
let result = this.temp(value_ty.clone());
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_mir/hair.rs
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ pub struct Expr<H:Hair> {
#[derive(Clone, Debug)]
pub enum ExprKind<H:Hair> {
Scope { extent: H::CodeExtent, value: ExprRef<H> },
Box { place: Option<ExprRef<H>>, value: ExprRef<H> },
Box { value: ExprRef<H> },
Call { fun: ExprRef<H>, args: Vec<ExprRef<H>> },
Deref { arg: ExprRef<H> }, // NOT overloaded!
Binary { op: BinOp, lhs: ExprRef<H>, rhs: ExprRef<H> }, // NOT overloaded!
Expand Down
13 changes: 4 additions & 9 deletions src/librustc_mir/tcx/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,11 +140,6 @@ impl<'a,'tcx:'a> Mirror<Cx<'a,'tcx>> for &'tcx hir::Expr {
}
}

hir::ExprUnary(hir::UnOp::UnUniq, ref arg) => {
assert!(!cx.tcx.is_method_call(self.id));
ExprKind::Box { place: None, value: arg.to_ref() }
}

hir::ExprUnary(op, ref arg) => {
if cx.tcx.is_method_call(self.id) {
overloaded_operator(cx, self, ty::MethodCall::expr(self.id),
Expand All @@ -154,10 +149,10 @@ impl<'a,'tcx:'a> Mirror<Cx<'a,'tcx>> for &'tcx hir::Expr {
let op = match op {
hir::UnOp::UnNot => UnOp::Not,
hir::UnOp::UnNeg => UnOp::Neg,
hir::UnOp::UnUniq | hir::UnOp::UnDeref => {
hir::UnOp::UnDeref => {
cx.tcx.sess.span_bug(
self.span,
&format!("operator should have been handled elsewhere {:?}", op));
"UnDeref should have been handled elsewhere");
}
};
ExprKind::Unary { op: op, arg: arg.to_ref() }
Expand Down Expand Up @@ -296,8 +291,8 @@ impl<'a,'tcx:'a> Mirror<Cx<'a,'tcx>> for &'tcx hir::Expr {
name: Field::Indexed(ident.node) },
hir::ExprCast(ref source, _) =>
ExprKind::Cast { source: source.to_ref() },
hir::ExprBox(ref place, ref value) =>
ExprKind::Box { place: place.to_ref(), value: value.to_ref() },
hir::ExprBox(ref value) =>
ExprKind::Box { value: value.to_ref() },
hir::ExprVec(ref fields) =>
ExprKind::Vec { fields: fields.to_ref() },
hir::ExprTup(ref fields) =>
Expand Down
8 changes: 4 additions & 4 deletions src/librustc_trans/trans/consts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -564,10 +564,10 @@ fn const_expr_unadjusted<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,

let is_float = ty.is_fp();
unsafe { match u {
hir::UnUniq | hir::UnDeref => const_deref(cx, te, ty).0,
hir::UnNot => llvm::LLVMConstNot(te),
hir::UnNeg if is_float => llvm::LLVMConstFNeg(te),
hir::UnNeg => llvm::LLVMConstNeg(te),
hir::UnDeref => const_deref(cx, te, ty).0,
hir::UnNot => llvm::LLVMConstNot(te),
hir::UnNeg if is_float => llvm::LLVMConstFNeg(te),
hir::UnNeg => llvm::LLVMConstNeg(te),
} }
},
hir::ExprField(ref base, field) => {
Expand Down
4 changes: 1 addition & 3 deletions src/librustc_trans/trans/debuginfo/create_scope_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -325,9 +325,7 @@ fn walk_expr(cx: &CrateContext,
hir::ExprTupField(ref sub_exp, _) =>
walk_expr(cx, &**sub_exp, scope_stack, scope_map),

hir::ExprBox(ref place, ref sub_expr) => {
place.as_ref().map(
|e| walk_expr(cx, &**e, scope_stack, scope_map));
hir::ExprBox(ref sub_expr) => {
walk_expr(cx, &**sub_expr, scope_stack, scope_map);
}

Expand Down
20 changes: 2 additions & 18 deletions src/librustc_trans/trans/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -673,7 +673,7 @@ fn trans_datum_unadjusted<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
hir::ExprIndex(ref base, ref idx) => {
trans_index(bcx, expr, &**base, &**idx, MethodCall::expr(expr.id))
}
hir::ExprBox(_, ref contents) => {
hir::ExprBox(ref contents) => {
// Special case for `Box<T>`
let box_ty = expr_ty(bcx, expr);
let contents_ty = expr_ty(bcx, &**contents);
Expand Down Expand Up @@ -1649,9 +1649,6 @@ fn trans_unary<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
};
immediate_rvalue_bcx(bcx, llneg, un_ty).to_expr_datumblock()
}
hir::UnUniq => {
trans_uniq_expr(bcx, expr, un_ty, sub_expr, expr_ty(bcx, sub_expr))
}
hir::UnDeref => {
let datum = unpack_datum!(bcx, trans(bcx, sub_expr));
deref_once(bcx, expr, datum, method_call)
Expand Down Expand Up @@ -2769,24 +2766,11 @@ fn expr_kind(tcx: &ty::ctxt, expr: &hir::Expr) -> ExprKind {

hir::ExprLit(_) | // Note: LitStr is carved out above
hir::ExprUnary(..) |
hir::ExprBox(None, _) |
hir::ExprBox(_) |
hir::ExprAddrOf(..) |
hir::ExprBinary(..) |
hir::ExprCast(..) => {
ExprKind::RvalueDatum
}

hir::ExprBox(Some(ref place), _) => {
// Special case `Box<T>` for now:
let def_id = match tcx.def_map.borrow().get(&place.id) {
Some(def) => def.def_id(),
None => panic!("no def for place"),
};
if tcx.lang_items.exchange_heap() == Some(def_id) {
ExprKind::RvalueDatum
} else {
ExprKind::RvalueDps
}
}
}
}
Loading