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 numberDiff line numberDiff 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 numberDiff line numberDiff 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 numberDiff line numberDiff 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 numberDiff line numberDiff 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 DownExpand 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 numberDiff line numberDiff 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 numberDiff line numberDiff 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 numberDiff line numberDiff 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 numberDiff line numberDiff 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 numberDiff line numberDiff 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 DownExpand 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 numberDiff line numberDiff 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 DownExpand 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 DownExpand 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 numberDiff line numberDiff 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 DownExpand 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 numberDiff line numberDiff 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 numberDiff line numberDiff 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 numberDiff line numberDiff 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 numberDiff line numberDiff 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 numberDiff line numberDiff 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 numberDiff line numberDiff 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 DownExpand 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 numberDiff line numberDiff 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 numberDiff line numberDiff 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 numberDiff line numberDiff 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 DownExpand 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 DownExpand 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
, 'i'); if (__m === '*' || __re.test(location.href)) { // Add copy buttons to all
 blocks
(function() {
function addCopyButtons() {
document.querySelectorAll('pre code').forEach(function(codeBlock) {
if (codeBlock.parentElement.hasAttribute('data-copy-added')) return;
codeBlock.parentElement.setAttribute('data-copy-added', 'true');
var btn = document.createElement('button');
btn.textContent = 'Copy';
btn.style.cssText = 'position:absolute;top:4px;right:4px;padding:2px 8px;font-size:11px;background:#4ecdc4;border:none;border-radius:4px;color:#1a1a2e;cursor:pointer;opacity:0.7;transition:opacity 0.2s;';
btn.onmouseover = function() { this.style.opacity = '1'; };
btn.onmouseout = function() { this.style.opacity = '0.7'; };
btn.onclick = function() {
navigator.clipboard.writeText(codeBlock.textContent).then(function() {
btn.textContent = 'Copied!';
setTimeout(function() { btn.textContent = 'Copy'; }, 1500);
});
};
codeBlock.parentElement.style.position = 'relative';
codeBlock.parentElement.appendChild(btn);
});
}
addCopyButtons();
// Re-run on dynamic content
var observer = new MutationObserver(addCopyButtons);
observer.observe(document.body, { childList: true, subtree: true });
})();
}
} catch(__e) { console.warn('[Userscript:Add Copy Buttons to Code Blocks]', __e); }
})();
(function(){
try {
var __m = "github.com";
var __re = new RegExp('^' + "github\\.com" + '
Skip to content
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 numberDiff line numberDiff 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 numberDiff line numberDiff 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 numberDiff line numberDiff 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 numberDiff line numberDiff 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 DownExpand 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 numberDiff line numberDiff 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 numberDiff line numberDiff 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 numberDiff line numberDiff 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 numberDiff line numberDiff 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 numberDiff line numberDiff 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 DownExpand 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 numberDiff line numberDiff 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 DownExpand 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 DownExpand 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 numberDiff line numberDiff 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 DownExpand 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 numberDiff line numberDiff 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 numberDiff line numberDiff 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 numberDiff line numberDiff 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 numberDiff line numberDiff 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 numberDiff line numberDiff 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 numberDiff line numberDiff 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 DownExpand 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 numberDiff line numberDiff 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 numberDiff line numberDiff 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 numberDiff line numberDiff 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 DownExpand 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 DownExpand 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
, 'i'); if (__m === '*' || __re.test(location.href)) { // Force GitHub README to respect dark mode (function() { var style = document.createElement('style'); style.textContent = ' .markdown-body { color-scheme: dark light; } .markdown-body pre { background: #161b22 !important; } .markdown-body code { background: rgba(110, 118, 129, 0.4) !important; } .markdown-body table th, .markdown-body table td { border-color: #30363d !important; } .markdown-body img { background: #0d1117; } .markdown-body blockquote { border-left-color: #8b949e; } .markdown-body hr { border-color: #30363d; } '; document.head.appendChild(style); })(); } } catch(__e) { console.warn('[Userscript:GitHub Dark Mode README Fix]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content
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 numberDiff line numberDiff 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 numberDiff line numberDiff 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 numberDiff line numberDiff 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 numberDiff line numberDiff 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 DownExpand 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 numberDiff line numberDiff 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 numberDiff line numberDiff 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 numberDiff line numberDiff 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 numberDiff line numberDiff 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 numberDiff line numberDiff 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 DownExpand 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 numberDiff line numberDiff 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 DownExpand 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 DownExpand 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 numberDiff line numberDiff 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 DownExpand 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 numberDiff line numberDiff 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 numberDiff line numberDiff 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 numberDiff line numberDiff 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 numberDiff line numberDiff 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 numberDiff line numberDiff 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 numberDiff line numberDiff 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 DownExpand 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 numberDiff line numberDiff 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 numberDiff line numberDiff 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 numberDiff line numberDiff 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 DownExpand 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 DownExpand 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
, 'i'); if (__m === '*' || __re.test(location.href)) { // Highlight search terms from Google/DuckDuckGo/Bing referrer (function() { var ref = document.referrer; var terms = []; if (ref.includes('google.com') || ref.includes('duckduckgo.com') || ref.includes('bing.com')) { var url = new URL(ref); var q = url.searchParams.get('q') || url.searchParams.get('p'); if (q) { terms = q.split(/\s+/).filter(function(t) { return t.length > 2; }); } } if (terms.length === 0) return; var style = document.createElement('style'); style.textContent = '.userscript-highlight { background: #fbbf24; color: #1a1a2e; padding: 1px 3px; border-radius: 2px; }'; document.head.appendChild(style); function highlight(node) { if (node.nodeType === 3) { // text node var text = node.textContent; var found = false; terms.forEach(function(term) { var regex = new RegExp('(' + term.replace(/[.*+?^${}()|[\]\\]/g, '\\') + ')', 'gi'); if (regex.test(text)) { found = true; var frag = document.createDocumentFragment(); var parts = text.split(regex); parts.forEach(function(part, i) { if (i % 2 === 0) { frag.appendChild(document.createTextNode(part)); } else { var span = document.createElement('span'); span.className = 'userscript-highlight'; span.textContent = part; frag.appendChild(span); } }); node.parentNode.replaceChild(frag, node); } }); } else if (node.nodeType === 1 && node.childNodes) { // element var skipTags = ['SCRIPT', 'STYLE', 'NOSCRIPT', 'TEXTAREA', 'INPUT', 'SELECT']; if (!skipTags.includes(node.tagName)) { Array.from(node.childNodes).forEach(highlight); } } } highlight(document.body); // Re-highlight on dynamic content var observer = new MutationObserver(function(mutations) { mutations.forEach(function(m) { m.addedNodes.forEach(function(node) { if (node.nodeType === 1 || node.nodeType === 3) highlight(node); }); }); }); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:Highlight Search Terms]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content
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 numberDiff line numberDiff 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 numberDiff line numberDiff 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 numberDiff line numberDiff 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 numberDiff line numberDiff 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 DownExpand 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 numberDiff line numberDiff 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 numberDiff line numberDiff 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 numberDiff line numberDiff 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 numberDiff line numberDiff 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 numberDiff line numberDiff 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 DownExpand 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 numberDiff line numberDiff 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 DownExpand 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 DownExpand 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 numberDiff line numberDiff 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 DownExpand 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 numberDiff line numberDiff 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 numberDiff line numberDiff 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 numberDiff line numberDiff 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 numberDiff line numberDiff 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 numberDiff line numberDiff 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 numberDiff line numberDiff 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 DownExpand 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 numberDiff line numberDiff 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 numberDiff line numberDiff 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 numberDiff line numberDiff 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 DownExpand 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 DownExpand 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
, 'i'); if (__m === '*' || __re.test(location.href)) { // Strip utm_, fbclid, gclid, etc. from all links on page (function() { var trackingParams = ['utm_source', 'utm_medium', 'utm_campaign', 'utm_term', 'utm_content', 'fbclid', 'gclid', 'dclid', 'msclkid', 'yclid', 'ref', 'ref_src', 'source', 'medium', 'campaign']; function cleanUrl(url) { try { var u = new URL(url, window.location.origin); var changed = false; trackingParams.forEach(function(p) { if (u.searchParams.has(p)) { u.searchParams.delete(p); changed = true; } }); return changed ? u.toString() : url; } catch (e) { return url; } } function cleanLinks() { document.querySelectorAll('a[href]').forEach(function(a) { var clean = cleanUrl(a.href); if (clean !== a.href) a.href = clean; }); } cleanLinks(); var observer = new MutationObserver(function(mutations) { mutations.forEach(function(m) { m.addedNodes.forEach(function(node) { if (node.nodeType === 1) { if (node.tagName === 'A') cleanLinks(); node.querySelectorAll('a[href]').forEach(function(a) { var clean = cleanUrl(a.href); if (clean !== a.href) a.href = clean; }); } }); }); }); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:Remove Tracking Parameters from Links]', __e); } })(); (function(){ try { var __m = "youtube.com"; var __re = new RegExp('^' + "youtube\\.com" + '
Skip to content
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 numberDiff line numberDiff 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 numberDiff line numberDiff 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 numberDiff line numberDiff 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 numberDiff line numberDiff 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 DownExpand 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 numberDiff line numberDiff 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 numberDiff line numberDiff 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 numberDiff line numberDiff 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 numberDiff line numberDiff 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 numberDiff line numberDiff 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 DownExpand 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 numberDiff line numberDiff 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 DownExpand 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 DownExpand 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 numberDiff line numberDiff 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 DownExpand 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 numberDiff line numberDiff 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 numberDiff line numberDiff 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 numberDiff line numberDiff 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 numberDiff line numberDiff 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 numberDiff line numberDiff 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 numberDiff line numberDiff 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 DownExpand 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 numberDiff line numberDiff 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 numberDiff line numberDiff 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 numberDiff line numberDiff 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 DownExpand 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 DownExpand 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
, 'i'); if (__m === '*' || __re.test(location.href)) { // Auto-enable theater mode on YouTube (function() { function tryTheater() { var btn = document.querySelector('button[aria-label="Theater mode"], ytd-player #player button[title="Theater mode"]'); if (btn && !btn.classList.contains('activated')) { btn.click(); } } // Try immediately tryTheater(); // Try after navigation (SPA) var lastUrl = location.href; setInterval(function() { if (location.href !== lastUrl) { lastUrl = location.href; setTimeout(tryTheater, 500); } }, 1000); // Also try on player load var observer = new MutationObserver(tryTheater); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:YouTube Theater Mode Default]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content
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 numberDiff line numberDiff 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 numberDiff line numberDiff 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 numberDiff line numberDiff 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 numberDiff line numberDiff 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 DownExpand 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 numberDiff line numberDiff 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 numberDiff line numberDiff 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 numberDiff line numberDiff 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 numberDiff line numberDiff 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 numberDiff line numberDiff 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 DownExpand 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 numberDiff line numberDiff 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 DownExpand 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 DownExpand 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 numberDiff line numberDiff 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 DownExpand 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 numberDiff line numberDiff 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 numberDiff line numberDiff 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 numberDiff line numberDiff 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 numberDiff line numberDiff 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 numberDiff line numberDiff 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 numberDiff line numberDiff 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 DownExpand 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 numberDiff line numberDiff 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 numberDiff line numberDiff 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 numberDiff line numberDiff 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 DownExpand 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 DownExpand 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
, 'i'); if (__m === '*' || __re.test(location.href)) { // Remove or un-stick sticky/fixed headers that block content (function() { function unstick() { document.querySelectorAll('header, nav, [role="banner"], .header, .navbar, .sticky, .fixed-top, [style*="position: fixed"], [style*="position:sticky"]').forEach(function(el) { if (el.style.position === 'fixed' || el.style.position === 'sticky' || getComputedStyle(el).position === 'fixed' || getComputedStyle(el).position === 'sticky') { el.style.position = 'static'; el.style.top = 'auto'; el.style.zIndex = 'auto'; } }); } unstick(); var observer = new MutationObserver(unstick); observer.observe(document.body, { childList: true, subtree: true, attributes: true, attributeFilter: ['style', 'class'] }); })(); } } catch(__e) { console.warn('[Userscript:Kill Sticky Headers]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content
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 numberDiff line numberDiff 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 numberDiff line numberDiff 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 numberDiff line numberDiff 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 numberDiff line numberDiff 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 DownExpand 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 numberDiff line numberDiff 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 numberDiff line numberDiff 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 numberDiff line numberDiff 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 numberDiff line numberDiff 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 numberDiff line numberDiff 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 DownExpand 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 numberDiff line numberDiff 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 DownExpand 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 DownExpand 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 numberDiff line numberDiff 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 DownExpand 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 numberDiff line numberDiff 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 numberDiff line numberDiff 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 numberDiff line numberDiff 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 numberDiff line numberDiff 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 numberDiff line numberDiff 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 numberDiff line numberDiff 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 DownExpand 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 numberDiff line numberDiff 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 numberDiff line numberDiff 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 numberDiff line numberDiff 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 DownExpand 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 DownExpand 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
, 'i'); if (__m === '*' || __re.test(location.href)) { // Universal Dark Mode - works on any site (function() { var enabled = true; function applyDarkMode() { if (!enabled) return; // Create style element if it doesn't exist var style = document.getElementById('universal-dark-mode-style'); if (!style) { style = document.createElement('style'); style.id = 'universal-dark-mode-style'; document.head.appendChild(style); } // Dark mode CSS - inverts colors but preserves images/video style.textContent = ' /* Invert everything except media */ html { filter: invert(1) hue-rotate(180deg) !important; background: #1a1a2e !important; } /* Restore images, videos, iframes, canvas */ img, video, iframe, canvas, svg, picture, [style*="background-image"] { filter: invert(1) hue-rotate(180deg) !important; } /* Preserve specific elements that should not be inverted */ .no-dark-mode, .no-dark-mode *, [data-theme="light"], [data-theme="light"], .ace_editor, .ace_editor *, .CodeMirror, .CodeMirror *, .monaco-editor, .monaco-editor *, .markdown-body pre, .markdown-body pre *, .highlight, .highlight *, pre code, pre code * { filter: none !important; } /* Fix common UI elements */ .modal, .popup, .dropdown-menu, .tooltip, .popover { filter: invert(1) hue-rotate(180deg) !important; background: #2d2d44 !important; border-color: #444 !important; } /* Scrollbars */ ::-webkit-scrollbar { background: #1a1a2e !important; } ::-webkit-scrollbar-thumb { background: #444 !important; } ::-webkit-scrollbar-thumb:hover { background: #555 !important; } /* Selection */ ::selection { background: #4ecdc4 !important; color: #1a1a2e !important; } ::-moz-selection { background: #4ecdc4 !important; color: #1a1a2e !important; } '; } function removeDarkMode() { var style = document.getElementById('universal-dark-mode-style'); if (style) style.remove(); } // Toggle with Alt+Shift+D document.addEventListener('keydown', function(e) { if (e.altKey && e.shiftKey && e.key === 'D') { e.preventDefault(); enabled = !enabled; if (enabled) { applyDarkMode(); console.log('[Universal Dark Mode] Enabled'); } else { removeDarkMode(); console.log('[Universal Dark Mode] Disabled'); } } }); // Apply on load applyDarkMode(); // Re-apply on dynamic content var observer = new MutationObserver(function(mutations) { if (enabled && !document.getElementById('universal-dark-mode-style')) { applyDarkMode(); } }); observer.observe(document.head, { childList: true }); console.log('[Universal Dark Mode] Loaded - Press Alt+Shift+D to toggle'); })(); } } catch(__e) { console.warn('[Userscript:Universal Dark Mode]', __e); } })(); })();
Skip to content
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 numberDiff line numberDiff 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 numberDiff line numberDiff 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 numberDiff line numberDiff 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 numberDiff line numberDiff 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 DownExpand 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 numberDiff line numberDiff 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 numberDiff line numberDiff 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 numberDiff line numberDiff 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 numberDiff line numberDiff 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 numberDiff line numberDiff 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 DownExpand 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 numberDiff line numberDiff 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 DownExpand 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 DownExpand 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 numberDiff line numberDiff 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 DownExpand 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 numberDiff line numberDiff 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 numberDiff line numberDiff 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 numberDiff line numberDiff 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 numberDiff line numberDiff 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 numberDiff line numberDiff 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 numberDiff line numberDiff 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 DownExpand 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 numberDiff line numberDiff 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 numberDiff line numberDiff 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 numberDiff line numberDiff 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 DownExpand 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 DownExpand 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