Remove the deprecated box(PLACE) syntax.
This commit is contained in:
parent
07ca1ab1ec
commit
f293ea28b4
50 changed files with 117 additions and 282 deletions
|
@ -80,11 +80,10 @@ use core::raw::{TraitObject};
|
||||||
/// use std::boxed::HEAP;
|
/// use std::boxed::HEAP;
|
||||||
///
|
///
|
||||||
/// fn main() {
|
/// fn main() {
|
||||||
/// let foo = box(HEAP) 5;
|
/// let foo: Box<i32> = in HEAP { 5 };
|
||||||
/// let foo = box 5;
|
/// let foo = box 5;
|
||||||
/// }
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
#[lang = "exchange_heap"]
|
|
||||||
#[unstable(feature = "box_heap",
|
#[unstable(feature = "box_heap",
|
||||||
reason = "may be renamed; uncertain about custom allocator design",
|
reason = "may be renamed; uncertain about custom allocator design",
|
||||||
issue = "27779")]
|
issue = "27779")]
|
||||||
|
|
|
@ -344,13 +344,12 @@ impl<'a, 'tcx> CFGBuilder<'a, 'tcx> {
|
||||||
self.straightline(expr, pred, [r, l].iter().map(|&e| &**e))
|
self.straightline(expr, pred, [r, l].iter().map(|&e| &**e))
|
||||||
}
|
}
|
||||||
|
|
||||||
hir::ExprBox(Some(ref l), ref r) |
|
|
||||||
hir::ExprIndex(ref l, ref r) |
|
hir::ExprIndex(ref l, ref r) |
|
||||||
hir::ExprBinary(_, ref l, ref r) => { // NB: && and || handled earlier
|
hir::ExprBinary(_, ref l, ref r) => { // NB: && and || handled earlier
|
||||||
self.straightline(expr, pred, [l, r].iter().map(|&e| &**e))
|
self.straightline(expr, pred, [l, r].iter().map(|&e| &**e))
|
||||||
}
|
}
|
||||||
|
|
||||||
hir::ExprBox(None, ref e) |
|
hir::ExprBox(ref e) |
|
||||||
hir::ExprAddrOf(_, ref e) |
|
hir::ExprAddrOf(_, ref e) |
|
||||||
hir::ExprCast(ref e, _) |
|
hir::ExprCast(ref e, _) |
|
||||||
hir::ExprUnary(_, ref e) |
|
hir::ExprUnary(_, ref e) |
|
||||||
|
|
|
@ -568,8 +568,7 @@ fn check_expr<'a, 'tcx>(v: &mut CheckCrateVisitor<'a, 'tcx>,
|
||||||
"user-defined operators are not allowed in {}s", v.msg());
|
"user-defined operators are not allowed in {}s", v.msg());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
hir::ExprBox(..) |
|
hir::ExprBox(_) => {
|
||||||
hir::ExprUnary(hir::UnUniq, _) => {
|
|
||||||
v.add_qualif(ConstQualif::NOT_CONST);
|
v.add_qualif(ConstQualif::NOT_CONST);
|
||||||
if v.mode != Mode::Var {
|
if v.mode != Mode::Var {
|
||||||
span_err!(v.tcx.sess, e.span, E0010,
|
span_err!(v.tcx.sess, e.span, E0010,
|
||||||
|
|
|
@ -280,13 +280,11 @@ impl<'d,'t,'a,'tcx> ExprUseVisitor<'d,'t,'a,'tcx> {
|
||||||
typer: &'t infer::InferCtxt<'a, 'tcx>)
|
typer: &'t infer::InferCtxt<'a, 'tcx>)
|
||||||
-> ExprUseVisitor<'d,'t,'a,'tcx>
|
-> ExprUseVisitor<'d,'t,'a,'tcx>
|
||||||
{
|
{
|
||||||
let result = ExprUseVisitor {
|
ExprUseVisitor {
|
||||||
typer: typer,
|
typer: typer,
|
||||||
mc: mc::MemCategorizationContext::new(typer),
|
mc: mc::MemCategorizationContext::new(typer),
|
||||||
delegate: delegate,
|
delegate: delegate,
|
||||||
};
|
}
|
||||||
|
|
||||||
result
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn walk_fn(&mut self,
|
pub fn walk_fn(&mut self,
|
||||||
|
@ -544,17 +542,8 @@ impl<'d,'t,'a,'tcx> ExprUseVisitor<'d,'t,'a,'tcx> {
|
||||||
self.walk_captures(expr)
|
self.walk_captures(expr)
|
||||||
}
|
}
|
||||||
|
|
||||||
hir::ExprBox(ref place, ref base) => {
|
hir::ExprBox(ref base) => {
|
||||||
match *place {
|
|
||||||
Some(ref place) => self.consume_expr(&**place),
|
|
||||||
None => {}
|
|
||||||
}
|
|
||||||
self.consume_expr(&**base);
|
self.consume_expr(&**base);
|
||||||
if place.is_some() {
|
|
||||||
self.tcx().sess.span_bug(
|
|
||||||
expr.span,
|
|
||||||
"box with explicit place remains after expansion");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -341,7 +341,6 @@ lets_do_this! {
|
||||||
EhUnwindResumeLangItem, "eh_unwind_resume", eh_unwind_resume;
|
EhUnwindResumeLangItem, "eh_unwind_resume", eh_unwind_resume;
|
||||||
MSVCTryFilterLangItem, "msvc_try_filter", msvc_try_filter;
|
MSVCTryFilterLangItem, "msvc_try_filter", msvc_try_filter;
|
||||||
|
|
||||||
ExchangeHeapLangItem, "exchange_heap", exchange_heap;
|
|
||||||
OwnedBoxLangItem, "owned_box", owned_box;
|
OwnedBoxLangItem, "owned_box", owned_box;
|
||||||
|
|
||||||
PhantomDataItem, "phantom_data", phantom_data;
|
PhantomDataItem, "phantom_data", phantom_data;
|
||||||
|
|
|
@ -1147,8 +1147,7 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
|
||||||
}
|
}
|
||||||
|
|
||||||
hir::ExprIndex(ref l, ref r) |
|
hir::ExprIndex(ref l, ref r) |
|
||||||
hir::ExprBinary(_, ref l, ref r) |
|
hir::ExprBinary(_, ref l, ref r) => {
|
||||||
hir::ExprBox(Some(ref l), ref r) => {
|
|
||||||
let r_succ = self.propagate_through_expr(&**r, succ);
|
let r_succ = self.propagate_through_expr(&**r, succ);
|
||||||
self.propagate_through_expr(&**l, r_succ)
|
self.propagate_through_expr(&**l, r_succ)
|
||||||
}
|
}
|
||||||
|
@ -1158,7 +1157,7 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
|
||||||
e1.as_ref().map_or(succ, |e| self.propagate_through_expr(&**e, succ))
|
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::ExprAddrOf(_, ref e) |
|
||||||
hir::ExprCast(ref e, _) |
|
hir::ExprCast(ref e, _) |
|
||||||
hir::ExprUnary(_, ref e) => {
|
hir::ExprUnary(_, ref e) => {
|
||||||
|
|
|
@ -994,9 +994,6 @@ fn resolve_local(visitor: &mut RegionResolutionVisitor, local: &hir::Local) {
|
||||||
visitor, &**subexpr, blk_id);
|
visitor, &**subexpr, blk_id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
hir::ExprUnary(hir::UnUniq, ref subexpr) => {
|
|
||||||
record_rvalue_scope_if_borrow_expr(visitor, &**subexpr, blk_id);
|
|
||||||
}
|
|
||||||
hir::ExprCast(ref subexpr, _) => {
|
hir::ExprCast(ref subexpr, _) => {
|
||||||
record_rvalue_scope_if_borrow_expr(visitor, &**subexpr, blk_id)
|
record_rvalue_scope_if_borrow_expr(visitor, &**subexpr, blk_id)
|
||||||
}
|
}
|
||||||
|
|
|
@ -1040,8 +1040,8 @@ pub fn noop_fold_expr<T: Folder>(Expr {id, node, span}: Expr, folder: &mut T) ->
|
||||||
Expr {
|
Expr {
|
||||||
id: folder.new_id(id),
|
id: folder.new_id(id),
|
||||||
node: match node {
|
node: match node {
|
||||||
ExprBox(p, e) => {
|
ExprBox(e) => {
|
||||||
ExprBox(p.map(|e|folder.fold_expr(e)), folder.fold_expr(e))
|
ExprBox(folder.fold_expr(e))
|
||||||
}
|
}
|
||||||
ExprVec(exprs) => {
|
ExprVec(exprs) => {
|
||||||
ExprVec(exprs.move_map(|x| folder.fold_expr(x)))
|
ExprVec(exprs.move_map(|x| folder.fold_expr(x)))
|
||||||
|
|
|
@ -491,8 +491,6 @@ pub type BinOp = Spanned<BinOp_>;
|
||||||
|
|
||||||
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug, Copy)]
|
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug, Copy)]
|
||||||
pub enum UnOp {
|
pub enum UnOp {
|
||||||
/// The `box` operator
|
|
||||||
UnUniq,
|
|
||||||
/// The `*` operator for dereferencing
|
/// The `*` operator for dereferencing
|
||||||
UnDeref,
|
UnDeref,
|
||||||
/// The `!` operator for logical inversion
|
/// The `!` operator for logical inversion
|
||||||
|
@ -595,8 +593,8 @@ impl fmt::Debug for Expr {
|
||||||
|
|
||||||
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
|
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
|
||||||
pub enum Expr_ {
|
pub enum Expr_ {
|
||||||
/// First expr is the place; second expr is the value.
|
/// A `box x` expression.
|
||||||
ExprBox(Option<P<Expr>>, P<Expr>),
|
ExprBox(P<Expr>),
|
||||||
/// An array (`[a, b, c, d]`)
|
/// An array (`[a, b, c, d]`)
|
||||||
ExprVec(Vec<P<Expr>>),
|
ExprVec(Vec<P<Expr>>),
|
||||||
/// A function call
|
/// A function call
|
||||||
|
|
|
@ -605,7 +605,6 @@ pub fn lower_constness(c: Constness) -> hir::Constness {
|
||||||
|
|
||||||
pub fn lower_unop(u: UnOp) -> hir::UnOp {
|
pub fn lower_unop(u: UnOp) -> hir::UnOp {
|
||||||
match u {
|
match u {
|
||||||
UnUniq => hir::UnUniq,
|
|
||||||
UnDeref => hir::UnDeref,
|
UnDeref => hir::UnDeref,
|
||||||
UnNot => hir::UnNot,
|
UnNot => hir::UnNot,
|
||||||
UnNeg => hir::UnNeg,
|
UnNeg => hir::UnNeg,
|
||||||
|
@ -694,8 +693,8 @@ pub fn lower_expr(e: &Expr) -> P<hir::Expr> {
|
||||||
P(hir::Expr {
|
P(hir::Expr {
|
||||||
id: e.id,
|
id: e.id,
|
||||||
node: match e.node {
|
node: match e.node {
|
||||||
ExprBox(ref p, ref e) => {
|
ExprBox(ref e) => {
|
||||||
hir::ExprBox(p.as_ref().map(|e| lower_expr(e)), lower_expr(e))
|
hir::ExprBox(lower_expr(e))
|
||||||
}
|
}
|
||||||
ExprVec(ref exprs) => {
|
ExprVec(ref exprs) => {
|
||||||
hir::ExprVec(exprs.iter().map(|x| lower_expr(x)).collect())
|
hir::ExprVec(exprs.iter().map(|x| lower_expr(x)).collect())
|
||||||
|
@ -818,6 +817,7 @@ pub fn lower_expr(e: &Expr) -> P<hir::Expr> {
|
||||||
ExprParen(ref ex) => {
|
ExprParen(ref ex) => {
|
||||||
return lower_expr(ex);
|
return lower_expr(ex);
|
||||||
}
|
}
|
||||||
|
ExprInPlace(..) |
|
||||||
ExprIfLet(..) |
|
ExprIfLet(..) |
|
||||||
ExprWhileLet(..) |
|
ExprWhileLet(..) |
|
||||||
ExprForLoop(..) |
|
ExprForLoop(..) |
|
||||||
|
|
|
@ -1182,16 +1182,6 @@ impl<'a> State<'a> {
|
||||||
Ok(())
|
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<()> {
|
fn print_expr_vec(&mut self, exprs: &[P<hir::Expr>]) -> io::Result<()> {
|
||||||
try!(self.ibox(indent_unit));
|
try!(self.ibox(indent_unit));
|
||||||
try!(word(&mut self.s, "["));
|
try!(word(&mut self.s, "["));
|
||||||
|
@ -1311,8 +1301,9 @@ impl<'a> State<'a> {
|
||||||
try!(self.ibox(indent_unit));
|
try!(self.ibox(indent_unit));
|
||||||
try!(self.ann.pre(self, NodeExpr(expr)));
|
try!(self.ann.pre(self, NodeExpr(expr)));
|
||||||
match expr.node {
|
match expr.node {
|
||||||
hir::ExprBox(ref place, ref expr) => {
|
hir::ExprBox(ref expr) => {
|
||||||
try!(self.print_expr_box(place, &**expr));
|
try!(self.word_space("box"));
|
||||||
|
try!(self.print_expr(expr));
|
||||||
}
|
}
|
||||||
hir::ExprVec(ref exprs) => {
|
hir::ExprVec(ref exprs) => {
|
||||||
try!(self.print_expr_vec(&exprs[..]));
|
try!(self.print_expr_vec(&exprs[..]));
|
||||||
|
|
|
@ -128,7 +128,6 @@ pub fn is_by_value_unop(u: UnOp) -> bool {
|
||||||
|
|
||||||
pub fn unop_to_string(op: UnOp) -> &'static str {
|
pub fn unop_to_string(op: UnOp) -> &'static str {
|
||||||
match op {
|
match op {
|
||||||
UnUniq => "box() ",
|
|
||||||
UnDeref => "*",
|
UnDeref => "*",
|
||||||
UnNot => "!",
|
UnNot => "!",
|
||||||
UnNeg => "-",
|
UnNeg => "-",
|
||||||
|
|
|
@ -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) {
|
pub fn walk_expr<'v, V: Visitor<'v>>(visitor: &mut V, expression: &'v Expr) {
|
||||||
match expression.node {
|
match expression.node {
|
||||||
ExprBox(ref place, ref subexpression) => {
|
ExprBox(ref subexpression) => {
|
||||||
place.as_ref().map(|e|visitor.visit_expr(&**e));
|
|
||||||
visitor.visit_expr(&**subexpression)
|
visitor.visit_expr(&**subexpression)
|
||||||
}
|
}
|
||||||
ExprVec(ref subexpressions) => {
|
ExprVec(ref subexpressions) => {
|
||||||
|
|
|
@ -442,7 +442,7 @@ impl LintPass for UnusedAllocation {
|
||||||
impl LateLintPass for UnusedAllocation {
|
impl LateLintPass for UnusedAllocation {
|
||||||
fn check_expr(&mut self, cx: &LateContext, e: &hir::Expr) {
|
fn check_expr(&mut self, cx: &LateContext, e: &hir::Expr) {
|
||||||
match e.node {
|
match e.node {
|
||||||
hir::ExprUnary(hir::UnUniq, _) => (),
|
hir::ExprBox(_) => {}
|
||||||
_ => return
|
_ => return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -67,7 +67,7 @@ impl<H:Hair> Builder<H> {
|
||||||
let arg = unpack!(block = this.as_operand(block, arg));
|
let arg = unpack!(block = this.as_operand(block, arg));
|
||||||
block.and(Rvalue::UnaryOp(op, arg))
|
block.and(Rvalue::UnaryOp(op, arg))
|
||||||
}
|
}
|
||||||
ExprKind::Box { place: _, value } => {
|
ExprKind::Box { value } => {
|
||||||
let value = this.hir.mirror(value);
|
let value = this.hir.mirror(value);
|
||||||
let value_ty = value.ty.clone();
|
let value_ty = value.ty.clone();
|
||||||
let result = this.temp(value_ty.clone());
|
let result = this.temp(value_ty.clone());
|
||||||
|
|
|
@ -171,7 +171,7 @@ pub struct Expr<H:Hair> {
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
pub enum ExprKind<H:Hair> {
|
pub enum ExprKind<H:Hair> {
|
||||||
Scope { extent: H::CodeExtent, value: ExprRef<H> },
|
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>> },
|
Call { fun: ExprRef<H>, args: Vec<ExprRef<H>> },
|
||||||
Deref { arg: ExprRef<H> }, // NOT overloaded!
|
Deref { arg: ExprRef<H> }, // NOT overloaded!
|
||||||
Binary { op: BinOp, lhs: ExprRef<H>, rhs: ExprRef<H> }, // NOT overloaded!
|
Binary { op: BinOp, lhs: ExprRef<H>, rhs: ExprRef<H> }, // NOT overloaded!
|
||||||
|
|
|
@ -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) => {
|
hir::ExprUnary(op, ref arg) => {
|
||||||
if cx.tcx.is_method_call(self.id) {
|
if cx.tcx.is_method_call(self.id) {
|
||||||
overloaded_operator(cx, self, ty::MethodCall::expr(self.id),
|
overloaded_operator(cx, self, ty::MethodCall::expr(self.id),
|
||||||
|
@ -154,10 +149,10 @@ impl<'a,'tcx:'a> Mirror<Cx<'a,'tcx>> for &'tcx hir::Expr {
|
||||||
let op = match op {
|
let op = match op {
|
||||||
hir::UnOp::UnNot => UnOp::Not,
|
hir::UnOp::UnNot => UnOp::Not,
|
||||||
hir::UnOp::UnNeg => UnOp::Neg,
|
hir::UnOp::UnNeg => UnOp::Neg,
|
||||||
hir::UnOp::UnUniq | hir::UnOp::UnDeref => {
|
hir::UnOp::UnDeref => {
|
||||||
cx.tcx.sess.span_bug(
|
cx.tcx.sess.span_bug(
|
||||||
self.span,
|
self.span,
|
||||||
&format!("operator should have been handled elsewhere {:?}", op));
|
"UnDeref should have been handled elsewhere");
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
ExprKind::Unary { op: op, arg: arg.to_ref() }
|
ExprKind::Unary { op: op, arg: arg.to_ref() }
|
||||||
|
@ -296,8 +291,8 @@ impl<'a,'tcx:'a> Mirror<Cx<'a,'tcx>> for &'tcx hir::Expr {
|
||||||
name: Field::Indexed(ident.node) },
|
name: Field::Indexed(ident.node) },
|
||||||
hir::ExprCast(ref source, _) =>
|
hir::ExprCast(ref source, _) =>
|
||||||
ExprKind::Cast { source: source.to_ref() },
|
ExprKind::Cast { source: source.to_ref() },
|
||||||
hir::ExprBox(ref place, ref value) =>
|
hir::ExprBox(ref value) =>
|
||||||
ExprKind::Box { place: place.to_ref(), value: value.to_ref() },
|
ExprKind::Box { value: value.to_ref() },
|
||||||
hir::ExprVec(ref fields) =>
|
hir::ExprVec(ref fields) =>
|
||||||
ExprKind::Vec { fields: fields.to_ref() },
|
ExprKind::Vec { fields: fields.to_ref() },
|
||||||
hir::ExprTup(ref fields) =>
|
hir::ExprTup(ref fields) =>
|
||||||
|
|
|
@ -564,7 +564,7 @@ fn const_expr_unadjusted<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
|
||||||
|
|
||||||
let is_float = ty.is_fp();
|
let is_float = ty.is_fp();
|
||||||
unsafe { match u {
|
unsafe { match u {
|
||||||
hir::UnUniq | hir::UnDeref => const_deref(cx, te, ty).0,
|
hir::UnDeref => const_deref(cx, te, ty).0,
|
||||||
hir::UnNot => llvm::LLVMConstNot(te),
|
hir::UnNot => llvm::LLVMConstNot(te),
|
||||||
hir::UnNeg if is_float => llvm::LLVMConstFNeg(te),
|
hir::UnNeg if is_float => llvm::LLVMConstFNeg(te),
|
||||||
hir::UnNeg => llvm::LLVMConstNeg(te),
|
hir::UnNeg => llvm::LLVMConstNeg(te),
|
||||||
|
|
|
@ -325,9 +325,7 @@ fn walk_expr(cx: &CrateContext,
|
||||||
hir::ExprTupField(ref sub_exp, _) =>
|
hir::ExprTupField(ref sub_exp, _) =>
|
||||||
walk_expr(cx, &**sub_exp, scope_stack, scope_map),
|
walk_expr(cx, &**sub_exp, scope_stack, scope_map),
|
||||||
|
|
||||||
hir::ExprBox(ref place, ref sub_expr) => {
|
hir::ExprBox(ref sub_expr) => {
|
||||||
place.as_ref().map(
|
|
||||||
|e| walk_expr(cx, &**e, scope_stack, scope_map));
|
|
||||||
walk_expr(cx, &**sub_expr, scope_stack, scope_map);
|
walk_expr(cx, &**sub_expr, scope_stack, scope_map);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -673,7 +673,7 @@ fn trans_datum_unadjusted<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
||||||
hir::ExprIndex(ref base, ref idx) => {
|
hir::ExprIndex(ref base, ref idx) => {
|
||||||
trans_index(bcx, expr, &**base, &**idx, MethodCall::expr(expr.id))
|
trans_index(bcx, expr, &**base, &**idx, MethodCall::expr(expr.id))
|
||||||
}
|
}
|
||||||
hir::ExprBox(_, ref contents) => {
|
hir::ExprBox(ref contents) => {
|
||||||
// Special case for `Box<T>`
|
// Special case for `Box<T>`
|
||||||
let box_ty = expr_ty(bcx, expr);
|
let box_ty = expr_ty(bcx, expr);
|
||||||
let contents_ty = expr_ty(bcx, &**contents);
|
let contents_ty = expr_ty(bcx, &**contents);
|
||||||
|
@ -1649,9 +1649,6 @@ fn trans_unary<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
||||||
};
|
};
|
||||||
immediate_rvalue_bcx(bcx, llneg, un_ty).to_expr_datumblock()
|
immediate_rvalue_bcx(bcx, llneg, un_ty).to_expr_datumblock()
|
||||||
}
|
}
|
||||||
hir::UnUniq => {
|
|
||||||
trans_uniq_expr(bcx, expr, un_ty, sub_expr, expr_ty(bcx, sub_expr))
|
|
||||||
}
|
|
||||||
hir::UnDeref => {
|
hir::UnDeref => {
|
||||||
let datum = unpack_datum!(bcx, trans(bcx, sub_expr));
|
let datum = unpack_datum!(bcx, trans(bcx, sub_expr));
|
||||||
deref_once(bcx, expr, datum, method_call)
|
deref_once(bcx, expr, datum, method_call)
|
||||||
|
@ -2769,24 +2766,11 @@ fn expr_kind(tcx: &ty::ctxt, expr: &hir::Expr) -> ExprKind {
|
||||||
|
|
||||||
hir::ExprLit(_) | // Note: LitStr is carved out above
|
hir::ExprLit(_) | // Note: LitStr is carved out above
|
||||||
hir::ExprUnary(..) |
|
hir::ExprUnary(..) |
|
||||||
hir::ExprBox(None, _) |
|
hir::ExprBox(_) |
|
||||||
hir::ExprAddrOf(..) |
|
hir::ExprAddrOf(..) |
|
||||||
hir::ExprBinary(..) |
|
hir::ExprBinary(..) |
|
||||||
hir::ExprCast(..) => {
|
hir::ExprCast(..) => {
|
||||||
ExprKind::RvalueDatum
|
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
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3212,31 +3212,16 @@ fn check_expr_with_unifier<'a, 'tcx, F>(fcx: &FnCtxt<'a, 'tcx>,
|
||||||
let tcx = fcx.ccx.tcx;
|
let tcx = fcx.ccx.tcx;
|
||||||
let id = expr.id;
|
let id = expr.id;
|
||||||
match expr.node {
|
match expr.node {
|
||||||
hir::ExprBox(ref opt_place, ref subexpr) => {
|
hir::ExprBox(ref subexpr) => {
|
||||||
opt_place.as_ref().map(|place|check_expr(fcx, &**place));
|
let expected_inner = expected.to_option(fcx).map_or(NoExpectation, |ty| {
|
||||||
check_expr(fcx, &**subexpr);
|
match ty.sty {
|
||||||
|
ty::TyBox(ty) => Expectation::rvalue_hint(tcx, ty),
|
||||||
let mut checked = false;
|
_ => NoExpectation
|
||||||
opt_place.as_ref().map(|place| match place.node {
|
|
||||||
hir::ExprPath(None, ref path) => {
|
|
||||||
// FIXME(pcwalton): For now we hardcode the only permissible
|
|
||||||
// place: the exchange heap.
|
|
||||||
let definition = lookup_full_def(tcx, path.span, place.id);
|
|
||||||
let def_id = definition.def_id();
|
|
||||||
let referent_ty = fcx.expr_ty(&**subexpr);
|
|
||||||
if tcx.lang_items.exchange_heap() == Some(def_id) {
|
|
||||||
fcx.write_ty(id, tcx.mk_box(referent_ty));
|
|
||||||
checked = true
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
_ => {}
|
|
||||||
});
|
});
|
||||||
|
check_expr_with_expectation(fcx, subexpr, expected_inner);
|
||||||
if !checked {
|
let referent_ty = fcx.expr_ty(&**subexpr);
|
||||||
span_err!(tcx.sess, expr.span, E0066,
|
fcx.write_ty(id, tcx.mk_box(referent_ty));
|
||||||
"only the exchange heap is currently supported");
|
|
||||||
fcx.write_ty(id, tcx.types.err);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
hir::ExprLit(ref lit) => {
|
hir::ExprLit(ref lit) => {
|
||||||
|
@ -3250,24 +3235,14 @@ fn check_expr_with_unifier<'a, 'tcx, F>(fcx: &FnCtxt<'a, 'tcx>,
|
||||||
op::check_binop_assign(fcx, expr, op, lhs, rhs);
|
op::check_binop_assign(fcx, expr, op, lhs, rhs);
|
||||||
}
|
}
|
||||||
hir::ExprUnary(unop, ref oprnd) => {
|
hir::ExprUnary(unop, ref oprnd) => {
|
||||||
let expected_inner = expected.to_option(fcx).map_or(NoExpectation, |ty| {
|
let expected_inner = match unop {
|
||||||
match unop {
|
|
||||||
hir::UnUniq => match ty.sty {
|
|
||||||
ty::TyBox(ty) => {
|
|
||||||
Expectation::rvalue_hint(tcx, ty)
|
|
||||||
}
|
|
||||||
_ => {
|
|
||||||
NoExpectation
|
|
||||||
}
|
|
||||||
},
|
|
||||||
hir::UnNot | hir::UnNeg => {
|
hir::UnNot | hir::UnNeg => {
|
||||||
expected
|
expected
|
||||||
}
|
}
|
||||||
hir::UnDeref => {
|
hir::UnDeref => {
|
||||||
NoExpectation
|
NoExpectation
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
});
|
|
||||||
let lvalue_pref = match unop {
|
let lvalue_pref = match unop {
|
||||||
hir::UnDeref => lvalue_pref,
|
hir::UnDeref => lvalue_pref,
|
||||||
_ => NoPreference
|
_ => NoPreference
|
||||||
|
@ -3278,9 +3253,6 @@ fn check_expr_with_unifier<'a, 'tcx, F>(fcx: &FnCtxt<'a, 'tcx>,
|
||||||
|
|
||||||
if !oprnd_t.references_error() {
|
if !oprnd_t.references_error() {
|
||||||
match unop {
|
match unop {
|
||||||
hir::UnUniq => {
|
|
||||||
oprnd_t = tcx.mk_box(oprnd_t);
|
|
||||||
}
|
|
||||||
hir::UnDeref => {
|
hir::UnDeref => {
|
||||||
oprnd_t = structurally_resolved_type(fcx, expr.span, oprnd_t);
|
oprnd_t = structurally_resolved_type(fcx, expr.span, oprnd_t);
|
||||||
oprnd_t = match oprnd_t.builtin_deref(true, NoPreference) {
|
oprnd_t = match oprnd_t.builtin_deref(true, NoPreference) {
|
||||||
|
|
|
@ -680,8 +680,6 @@ pub type BinOp = Spanned<BinOp_>;
|
||||||
|
|
||||||
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug, Copy)]
|
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug, Copy)]
|
||||||
pub enum UnOp {
|
pub enum UnOp {
|
||||||
/// The `box` operator
|
|
||||||
UnUniq,
|
|
||||||
/// The `*` operator for dereferencing
|
/// The `*` operator for dereferencing
|
||||||
UnDeref,
|
UnDeref,
|
||||||
/// The `!` operator for logical inversion
|
/// The `!` operator for logical inversion
|
||||||
|
@ -799,8 +797,10 @@ impl fmt::Debug for Expr {
|
||||||
|
|
||||||
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
|
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
|
||||||
pub enum Expr_ {
|
pub enum Expr_ {
|
||||||
|
/// A `box x` expression.
|
||||||
|
ExprBox(P<Expr>),
|
||||||
/// First expr is the place; second expr is the value.
|
/// First expr is the place; second expr is the value.
|
||||||
ExprBox(Option<P<Expr>>, P<Expr>),
|
ExprInPlace(P<Expr>, P<Expr>),
|
||||||
/// An array (`[a, b, c, d]`)
|
/// An array (`[a, b, c, d]`)
|
||||||
ExprVec(Vec<P<Expr>>),
|
ExprVec(Vec<P<Expr>>),
|
||||||
/// A function call
|
/// A function call
|
||||||
|
|
|
@ -101,7 +101,6 @@ pub fn is_by_value_unop(u: UnOp) -> bool {
|
||||||
|
|
||||||
pub fn unop_to_string(op: UnOp) -> &'static str {
|
pub fn unop_to_string(op: UnOp) -> &'static str {
|
||||||
match op {
|
match op {
|
||||||
UnUniq => "box() ",
|
|
||||||
UnDeref => "*",
|
UnDeref => "*",
|
||||||
UnNot => "!",
|
UnNot => "!",
|
||||||
UnNeg => "-",
|
UnNeg => "-",
|
||||||
|
|
|
@ -94,8 +94,8 @@ pub fn expand_expr(e: P<ast::Expr>, fld: &mut MacroExpander) -> P<ast::Expr> {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// Desugar ExprBox: `in (PLACE) EXPR`
|
// Desugar ExprInPlace: `in PLACE { EXPR }`
|
||||||
ast::ExprBox(Some(placer), value_expr) => {
|
ast::ExprInPlace(placer, value_expr) => {
|
||||||
// to:
|
// to:
|
||||||
//
|
//
|
||||||
// let p = PLACE;
|
// let p = PLACE;
|
||||||
|
|
|
@ -707,11 +707,11 @@ impl<'a, 'v> Visitor<'v> for MacroVisitor<'a> {
|
||||||
// But we keep these checks as a pre-expansion check to catch
|
// But we keep these checks as a pre-expansion check to catch
|
||||||
// uses in e.g. conditionalized code.
|
// uses in e.g. conditionalized code.
|
||||||
|
|
||||||
if let ast::ExprBox(None, _) = e.node {
|
if let ast::ExprBox(_) = e.node {
|
||||||
self.context.gate_feature("box_syntax", e.span, EXPLAIN_BOX_SYNTAX);
|
self.context.gate_feature("box_syntax", e.span, EXPLAIN_BOX_SYNTAX);
|
||||||
}
|
}
|
||||||
|
|
||||||
if let ast::ExprBox(Some(_), _) = e.node {
|
if let ast::ExprInPlace(..) = e.node {
|
||||||
self.context.gate_feature("placement_in_syntax", e.span, EXPLAIN_PLACEMENT_IN);
|
self.context.gate_feature("placement_in_syntax", e.span, EXPLAIN_PLACEMENT_IN);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -860,7 +860,7 @@ impl<'a, 'v> Visitor<'v> for PostExpansionVisitor<'a> {
|
||||||
|
|
||||||
fn visit_expr(&mut self, e: &ast::Expr) {
|
fn visit_expr(&mut self, e: &ast::Expr) {
|
||||||
match e.node {
|
match e.node {
|
||||||
ast::ExprBox(..) | ast::ExprUnary(ast::UnOp::UnUniq, _) => {
|
ast::ExprBox(_) => {
|
||||||
self.gate_feature("box_syntax",
|
self.gate_feature("box_syntax",
|
||||||
e.span,
|
e.span,
|
||||||
"box expression syntax is experimental; \
|
"box expression syntax is experimental; \
|
||||||
|
|
|
@ -1188,8 +1188,11 @@ pub fn noop_fold_expr<T: Folder>(Expr {id, node, span}: Expr, folder: &mut T) ->
|
||||||
Expr {
|
Expr {
|
||||||
id: folder.new_id(id),
|
id: folder.new_id(id),
|
||||||
node: match node {
|
node: match node {
|
||||||
ExprBox(p, e) => {
|
ExprBox(e) => {
|
||||||
ExprBox(p.map(|e|folder.fold_expr(e)), folder.fold_expr(e))
|
ExprBox(folder.fold_expr(e))
|
||||||
|
}
|
||||||
|
ExprInPlace(p, e) => {
|
||||||
|
ExprInPlace(folder.fold_expr(p), folder.fold_expr(e))
|
||||||
}
|
}
|
||||||
ExprVec(exprs) => {
|
ExprVec(exprs) => {
|
||||||
ExprVec(exprs.move_map(|x| folder.fold_expr(x)))
|
ExprVec(exprs.move_map(|x| folder.fold_expr(x)))
|
||||||
|
|
|
@ -22,7 +22,7 @@ use ast::{Decl, DeclItem, DeclLocal, DefaultBlock, DefaultReturn};
|
||||||
use ast::{UnDeref, BiDiv, EMPTY_CTXT, EnumDef, ExplicitSelf};
|
use ast::{UnDeref, BiDiv, EMPTY_CTXT, EnumDef, ExplicitSelf};
|
||||||
use ast::{Expr, Expr_, ExprAddrOf, ExprMatch, ExprAgain};
|
use ast::{Expr, Expr_, ExprAddrOf, ExprMatch, ExprAgain};
|
||||||
use ast::{ExprAssign, ExprAssignOp, ExprBinary, ExprBlock, ExprBox};
|
use ast::{ExprAssign, ExprAssignOp, ExprBinary, ExprBlock, ExprBox};
|
||||||
use ast::{ExprBreak, ExprCall, ExprCast};
|
use ast::{ExprBreak, ExprCall, ExprCast, ExprInPlace};
|
||||||
use ast::{ExprField, ExprTupField, ExprClosure, ExprIf, ExprIfLet, ExprIndex};
|
use ast::{ExprField, ExprTupField, ExprClosure, ExprIf, ExprIfLet, ExprIndex};
|
||||||
use ast::{ExprLit, ExprLoop, ExprMac, ExprRange};
|
use ast::{ExprLit, ExprLoop, ExprMac, ExprRange};
|
||||||
use ast::{ExprMethodCall, ExprParen, ExprPath};
|
use ast::{ExprMethodCall, ExprParen, ExprPath};
|
||||||
|
@ -54,7 +54,7 @@ use ast::{TupleVariantKind, Ty, Ty_, TypeBinding};
|
||||||
use ast::{TyMac};
|
use ast::{TyMac};
|
||||||
use ast::{TyFixedLengthVec, TyBareFn, TyTypeof, TyInfer};
|
use ast::{TyFixedLengthVec, TyBareFn, TyTypeof, TyInfer};
|
||||||
use ast::{TyParam, TyParamBound, TyParen, TyPath, TyPolyTraitRef, TyPtr};
|
use ast::{TyParam, TyParamBound, TyParen, TyPath, TyPolyTraitRef, TyPtr};
|
||||||
use ast::{TyRptr, TyTup, TyU32, TyVec, UnUniq};
|
use ast::{TyRptr, TyTup, TyU32, TyVec};
|
||||||
use ast::{TypeImplItem, TypeTraitItem};
|
use ast::{TypeImplItem, TypeTraitItem};
|
||||||
use ast::{UnnamedField, UnsafeBlock};
|
use ast::{UnnamedField, UnsafeBlock};
|
||||||
use ast::{ViewPath, ViewPathGlob, ViewPathList, ViewPathSimple};
|
use ast::{ViewPath, ViewPathGlob, ViewPathList, ViewPathSimple};
|
||||||
|
@ -2617,76 +2617,19 @@ impl<'a> Parser<'a> {
|
||||||
hi = e.span.hi;
|
hi = e.span.hi;
|
||||||
ex = ExprAddrOf(m, e);
|
ex = ExprAddrOf(m, e);
|
||||||
}
|
}
|
||||||
token::Ident(_, _) => {
|
token::Ident(..) if self.token.is_keyword(keywords::In) => {
|
||||||
if !self.check_keyword(keywords::Box) && !self.check_keyword(keywords::In) {
|
|
||||||
return self.parse_dot_or_call_expr();
|
|
||||||
}
|
|
||||||
|
|
||||||
let lo = self.span.lo;
|
|
||||||
let keyword_hi = self.span.hi;
|
|
||||||
|
|
||||||
let is_in = self.token.is_keyword(keywords::In);
|
|
||||||
try!(self.bump());
|
try!(self.bump());
|
||||||
|
|
||||||
if is_in {
|
|
||||||
let place = try!(self.parse_expr_res(Restrictions::RESTRICTION_NO_STRUCT_LITERAL));
|
let place = try!(self.parse_expr_res(Restrictions::RESTRICTION_NO_STRUCT_LITERAL));
|
||||||
let blk = try!(self.parse_block());
|
let blk = try!(self.parse_block());
|
||||||
hi = blk.span.hi;
|
hi = blk.span.hi;
|
||||||
let blk_expr = self.mk_expr(blk.span.lo, blk.span.hi, ExprBlock(blk));
|
let blk_expr = self.mk_expr(blk.span.lo, blk.span.hi, ExprBlock(blk));
|
||||||
ex = ExprBox(Some(place), blk_expr);
|
ex = ExprInPlace(place, blk_expr);
|
||||||
return Ok(self.mk_expr(lo, hi, ex));
|
|
||||||
}
|
|
||||||
|
|
||||||
// FIXME (#22181) Remove `box (PLACE) EXPR` support
|
|
||||||
// entirely after next release (enabling `(box (EXPR))`),
|
|
||||||
// since it will be replaced by `in PLACE { EXPR }`, ...
|
|
||||||
//
|
|
||||||
// ... but for now: check for a place: `box(PLACE) EXPR`.
|
|
||||||
|
|
||||||
if try!(self.eat(&token::OpenDelim(token::Paren))) {
|
|
||||||
let box_span = mk_sp(lo, self.last_span.hi);
|
|
||||||
self.span_warn(box_span,
|
|
||||||
"deprecated syntax; use the `in` keyword now \
|
|
||||||
(e.g. change `box (<expr>) <expr>` to \
|
|
||||||
`in <expr> { <expr> }`)");
|
|
||||||
|
|
||||||
// Continue supporting `box () EXPR` (temporarily)
|
|
||||||
if !try!(self.eat(&token::CloseDelim(token::Paren))) {
|
|
||||||
let place = try!(self.parse_expr_nopanic());
|
|
||||||
try!(self.expect(&token::CloseDelim(token::Paren)));
|
|
||||||
// Give a suggestion to use `box()` when a parenthesised expression is used
|
|
||||||
if !self.token.can_begin_expr() {
|
|
||||||
let span = self.span;
|
|
||||||
let this_token_to_string = self.this_token_to_string();
|
|
||||||
self.span_err(span,
|
|
||||||
&format!("expected expression, found `{}`",
|
|
||||||
this_token_to_string));
|
|
||||||
|
|
||||||
// Spanning just keyword avoids constructing
|
|
||||||
// printout of arg expression (which starts
|
|
||||||
// with parenthesis, as established above).
|
|
||||||
|
|
||||||
let box_span = mk_sp(lo, keyword_hi);
|
|
||||||
self.span_suggestion(box_span,
|
|
||||||
"try using `box ()` instead:",
|
|
||||||
format!("box ()"));
|
|
||||||
self.abort_if_errors();
|
|
||||||
}
|
}
|
||||||
|
token::Ident(..) if self.token.is_keyword(keywords::Box) => {
|
||||||
|
try!(self.bump());
|
||||||
let subexpression = try!(self.parse_prefix_expr());
|
let subexpression = try!(self.parse_prefix_expr());
|
||||||
hi = subexpression.span.hi;
|
hi = subexpression.span.hi;
|
||||||
ex = ExprBox(Some(place), subexpression);
|
ex = ExprBox(subexpression);
|
||||||
return Ok(self.mk_expr(lo, hi, ex));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Otherwise, we use the unique pointer default.
|
|
||||||
let subexpression = try!(self.parse_prefix_expr());
|
|
||||||
hi = subexpression.span.hi;
|
|
||||||
|
|
||||||
// FIXME (pnkfelix): After working out kinks with box
|
|
||||||
// desugaring, should be `ExprBox(None, subexpression)`
|
|
||||||
// instead.
|
|
||||||
ex = self.mk_unary(UnUniq, subexpression);
|
|
||||||
}
|
}
|
||||||
_ => return self.parse_dot_or_call_expr()
|
_ => return self.parse_dot_or_call_expr()
|
||||||
}
|
}
|
||||||
|
|
|
@ -1811,13 +1811,12 @@ impl<'a> State<'a> {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn print_expr_box(&mut self,
|
fn print_expr_in_place(&mut self,
|
||||||
place: &Option<P<ast::Expr>>,
|
place: &ast::Expr,
|
||||||
expr: &ast::Expr) -> io::Result<()> {
|
expr: &ast::Expr) -> io::Result<()> {
|
||||||
try!(word(&mut self.s, "box"));
|
try!(self.word_space("in"));
|
||||||
try!(word(&mut self.s, "("));
|
try!(self.print_expr(place));
|
||||||
try!(place.as_ref().map_or(Ok(()), |e|self.print_expr(&**e)));
|
try!(space(&mut self.s));
|
||||||
try!(self.word_space(")"));
|
|
||||||
self.print_expr(expr)
|
self.print_expr(expr)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1948,8 +1947,12 @@ impl<'a> State<'a> {
|
||||||
try!(self.ibox(indent_unit));
|
try!(self.ibox(indent_unit));
|
||||||
try!(self.ann.pre(self, NodeExpr(expr)));
|
try!(self.ann.pre(self, NodeExpr(expr)));
|
||||||
match expr.node {
|
match expr.node {
|
||||||
ast::ExprBox(ref place, ref expr) => {
|
ast::ExprBox(ref expr) => {
|
||||||
try!(self.print_expr_box(place, &**expr));
|
try!(self.word_space("box"));
|
||||||
|
try!(self.print_expr(expr));
|
||||||
|
}
|
||||||
|
ast::ExprInPlace(ref place, ref expr) => {
|
||||||
|
try!(self.print_expr_in_place(place, expr));
|
||||||
}
|
}
|
||||||
ast::ExprVec(ref exprs) => {
|
ast::ExprVec(ref exprs) => {
|
||||||
try!(self.print_expr_vec(&exprs[..]));
|
try!(self.print_expr_vec(&exprs[..]));
|
||||||
|
|
|
@ -735,8 +735,11 @@ pub fn walk_mac<'v, V: Visitor<'v>>(_: &mut V, _: &'v Mac) {
|
||||||
|
|
||||||
pub fn walk_expr<'v, V: Visitor<'v>>(visitor: &mut V, expression: &'v Expr) {
|
pub fn walk_expr<'v, V: Visitor<'v>>(visitor: &mut V, expression: &'v Expr) {
|
||||||
match expression.node {
|
match expression.node {
|
||||||
ExprBox(ref place, ref subexpression) => {
|
ExprBox(ref subexpression) => {
|
||||||
place.as_ref().map(|e|visitor.visit_expr(&**e));
|
visitor.visit_expr(&**subexpression)
|
||||||
|
}
|
||||||
|
ExprInPlace(ref place, ref subexpression) => {
|
||||||
|
visitor.visit_expr(&**place);
|
||||||
visitor.visit_expr(&**subexpression)
|
visitor.visit_expr(&**subexpression)
|
||||||
}
|
}
|
||||||
ExprVec(ref subexpressions) => {
|
ExprVec(ref subexpressions) => {
|
||||||
|
|
|
@ -22,5 +22,5 @@ pub trait i<T>
|
||||||
pub fn f<T>() -> Box<i<T>+'static> {
|
pub fn f<T>() -> Box<i<T>+'static> {
|
||||||
impl<T> i<T> for () { }
|
impl<T> i<T> for () { }
|
||||||
|
|
||||||
box() () as Box<i<T>+'static>
|
box () as Box<i<T>+'static>
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,8 +23,7 @@ fn for_func<F>(_f: F) where F: FnOnce() -> bool { panic!() }
|
||||||
fn produce<T>() -> T { panic!(); }
|
fn produce<T>() -> T { panic!(); }
|
||||||
|
|
||||||
fn inc(v: &mut Box<isize>) {
|
fn inc(v: &mut Box<isize>) {
|
||||||
*v = box() (**v + 1);
|
*v = box (**v + 1);
|
||||||
//~^ WARN deprecated syntax
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn pre_freeze_cond() {
|
fn pre_freeze_cond() {
|
||||||
|
|
|
@ -22,8 +22,7 @@ fn cond() -> bool { panic!() }
|
||||||
fn produce<T>() -> T { panic!(); }
|
fn produce<T>() -> T { panic!(); }
|
||||||
|
|
||||||
fn inc(v: &mut Box<isize>) {
|
fn inc(v: &mut Box<isize>) {
|
||||||
*v = box() (**v + 1);
|
*v = box (**v + 1);
|
||||||
//~^ WARN deprecated syntax
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn loop_overarching_alias_mut() {
|
fn loop_overarching_alias_mut() {
|
||||||
|
|
|
@ -23,8 +23,7 @@ fn for_func<F>(_f: F) where F: FnOnce() -> bool { panic!() }
|
||||||
fn produce<T>() -> T { panic!(); }
|
fn produce<T>() -> T { panic!(); }
|
||||||
|
|
||||||
fn inc(v: &mut Box<isize>) {
|
fn inc(v: &mut Box<isize>) {
|
||||||
*v = box() (**v + 1);
|
*v = box (**v + 1);
|
||||||
//~^ WARN deprecated syntax
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn pre_freeze() {
|
fn pre_freeze() {
|
||||||
|
|
|
@ -22,8 +22,7 @@ impl Add for foo {
|
||||||
fn add(self, f: foo) -> foo {
|
fn add(self, f: foo) -> foo {
|
||||||
let foo(box i) = self;
|
let foo(box i) = self;
|
||||||
let foo(box j) = f;
|
let foo(box j) = f;
|
||||||
foo(box() (i + j))
|
foo(box (i + j))
|
||||||
//~^ WARN deprecated syntax
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,8 +19,4 @@
|
||||||
fn main() {
|
fn main() {
|
||||||
let x = box 'c'; //~ ERROR box expression syntax is experimental
|
let x = box 'c'; //~ ERROR box expression syntax is experimental
|
||||||
println!("x: {}", x);
|
println!("x: {}", x);
|
||||||
|
|
||||||
let x = box () 'c'; //~ ERROR box expression syntax is experimental
|
|
||||||
//~^ WARN deprecated syntax
|
|
||||||
println!("x: {}", x);
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,10 +19,6 @@
|
||||||
fn main() {
|
fn main() {
|
||||||
use std::boxed::HEAP;
|
use std::boxed::HEAP;
|
||||||
|
|
||||||
let x = box (HEAP) 'c'; //~ ERROR placement-in expression syntax is experimental
|
|
||||||
//~^ WARN deprecated syntax
|
|
||||||
println!("x: {}", x);
|
|
||||||
|
|
||||||
let x = in HEAP { 'c' }; //~ ERROR placement-in expression syntax is experimental
|
let x = in HEAP { 'c' }; //~ ERROR placement-in expression syntax is experimental
|
||||||
println!("x: {}", x);
|
println!("x: {}", x);
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,8 +12,7 @@
|
||||||
#![feature(placement_in_syntax)]
|
#![feature(placement_in_syntax)]
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
box ( () ) 0;
|
in () { 0 };
|
||||||
//~^ ERROR: the trait `core::ops::Placer<_>` is not implemented
|
//~^ ERROR: the trait `core::ops::Placer<_>` is not implemented
|
||||||
//~| ERROR: the trait `core::ops::Placer<_>` is not implemented
|
//~| ERROR: the trait `core::ops::Placer<_>` is not implemented
|
||||||
//~| WARN deprecated syntax
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,8 +11,7 @@
|
||||||
#![feature(box_syntax)]
|
#![feature(box_syntax)]
|
||||||
|
|
||||||
fn dup(x: Box<isize>) -> Box<(Box<isize>,Box<isize>)> {
|
fn dup(x: Box<isize>) -> Box<(Box<isize>,Box<isize>)> {
|
||||||
box() (x, x) //~ ERROR use of moved value
|
box (x, x) //~ ERROR use of moved value
|
||||||
//~^ WARN deprecated syntax
|
|
||||||
}
|
}
|
||||||
fn main() {
|
fn main() {
|
||||||
dup(box 3);
|
dup(box 3);
|
||||||
|
|
|
@ -50,7 +50,7 @@ fn main() {
|
||||||
let stack_val_ref: &(i16, f32) = &stack_val;
|
let stack_val_ref: &(i16, f32) = &stack_val;
|
||||||
let ref_to_unnamed: &(i16, f32) = &(-15, -20f32);
|
let ref_to_unnamed: &(i16, f32) = &(-15, -20f32);
|
||||||
|
|
||||||
let unique_val: Box<(i16, f32)> = box() (-17, -22f32);
|
let unique_val: Box<(i16, f32)> = box (-17, -22f32);
|
||||||
let unique_val_ref: &(i16, f32) = &*unique_val;
|
let unique_val_ref: &(i16, f32) = &*unique_val;
|
||||||
|
|
||||||
zzz(); // #break
|
zzz(); // #break
|
||||||
|
|
|
@ -37,7 +37,7 @@
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let a = box 1;
|
let a = box 1;
|
||||||
let b = box() (2, 3.5f64);
|
let b = box (2, 3.5f64);
|
||||||
|
|
||||||
zzz(); // #break
|
zzz(); // #break
|
||||||
}
|
}
|
||||||
|
|
|
@ -433,7 +433,7 @@ fn main() {
|
||||||
managed_box(&(34, 35));
|
managed_box(&(34, 35));
|
||||||
borrowed_pointer(&(36, 37));
|
borrowed_pointer(&(36, 37));
|
||||||
contained_borrowed_pointer((&38, 39));
|
contained_borrowed_pointer((&38, 39));
|
||||||
unique_pointer(box() (40, 41, 42));
|
unique_pointer(box (40, 41, 42));
|
||||||
ref_binding((43, 44, 45));
|
ref_binding((43, 44, 45));
|
||||||
ref_binding_in_tuple((46, (47, 48)));
|
ref_binding_in_tuple((46, (47, 48)));
|
||||||
ref_binding_in_struct(Struct { a: 49, b: 50 });
|
ref_binding_in_struct(Struct { a: 49, b: 50 });
|
||||||
|
|
|
@ -304,7 +304,7 @@ fn main() {
|
||||||
let (&cc, _) = (&38, 39);
|
let (&cc, _) = (&38, 39);
|
||||||
|
|
||||||
// unique pointer
|
// unique pointer
|
||||||
let box dd = box() (40, 41, 42);
|
let box dd = box (40, 41, 42);
|
||||||
|
|
||||||
// ref binding
|
// ref binding
|
||||||
let ref ee = (43, 44, 45);
|
let ref ee = (43, 44, 45);
|
||||||
|
|
|
@ -1,19 +0,0 @@
|
||||||
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
|
|
||||||
// file at the top-level directory of this distribution and at
|
|
||||||
// http://rust-lang.org/COPYRIGHT.
|
|
||||||
//
|
|
||||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
|
||||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
|
||||||
// option. This file may not be copied, modified, or distributed
|
|
||||||
// except according to those terms.
|
|
||||||
|
|
||||||
// compile-flags: -Z parse-only
|
|
||||||
|
|
||||||
fn main() {
|
|
||||||
box (1 + 1)
|
|
||||||
//~^ HELP try using `box ()` instead:
|
|
||||||
//~| SUGGESTION box () (1 + 1)
|
|
||||||
//~| WARN deprecated syntax
|
|
||||||
; //~ ERROR expected expression, found `;`
|
|
||||||
}
|
|
|
@ -21,6 +21,6 @@ impl double for usize {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn main() {
|
pub fn main() {
|
||||||
let x: Box<_> = box() (box 3usize as Box<double>);
|
let x: Box<_> = box (box 3usize as Box<double>);
|
||||||
assert_eq!(x.double(), 6);
|
assert_eq!(x.double(), 6);
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,7 +24,7 @@ extern crate crate_method_reexport_grrrrrrr2;
|
||||||
pub fn main() {
|
pub fn main() {
|
||||||
use crate_method_reexport_grrrrrrr2::rust::add;
|
use crate_method_reexport_grrrrrrr2::rust::add;
|
||||||
use crate_method_reexport_grrrrrrr2::rust::cx;
|
use crate_method_reexport_grrrrrrr2::rust::cx;
|
||||||
let x: Box<_> = box () ();
|
let x: Box<_> = box ();
|
||||||
x.cx();
|
x.cx();
|
||||||
let y = ();
|
let y = ();
|
||||||
y.add("hi".to_string());
|
y.add("hi".to_string());
|
||||||
|
|
|
@ -16,5 +16,5 @@
|
||||||
pub fn main() {
|
pub fn main() {
|
||||||
fn f() {
|
fn f() {
|
||||||
};
|
};
|
||||||
let _: Box<fn()> = box() (f as fn());
|
let _: Box<fn()> = box (f as fn());
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,7 +28,7 @@ pub fn main() {
|
||||||
// let y = box ({a: 4});
|
// let y = box ({a: 4});
|
||||||
// let z = box ({a: 4} as it);
|
// let z = box ({a: 4} as it);
|
||||||
// let z = box ({a: true} as it);
|
// let z = box ({a: true} as it);
|
||||||
let z: Box<_> = box () (box true as Box<it>);
|
let z: Box<_> = box (box true as Box<it>);
|
||||||
// x.f();
|
// x.f();
|
||||||
// y.f();
|
// y.f();
|
||||||
// (*z).f();
|
// (*z).f();
|
||||||
|
|
|
@ -31,10 +31,10 @@ struct Structure {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn main() {
|
pub fn main() {
|
||||||
let x: Box<isize> = box(HEAP) 2;
|
let x: Box<isize> = in HEAP { 2 };
|
||||||
let y: Box<isize> = box 2;
|
let y: Box<isize> = box 2;
|
||||||
let b: Box<isize> = box()(1 + 2);
|
let b: Box<isize> = box (1 + 2);
|
||||||
let c = box()(3 + 4);
|
let c = box (3 + 4);
|
||||||
|
|
||||||
let s: Box<Structure> = box Structure {
|
let s: Box<Structure> = box Structure {
|
||||||
x: 3,
|
x: 3,
|
||||||
|
|
|
@ -83,7 +83,7 @@ impl<'s> Trait<'s> for (isize,isize) {
|
||||||
|
|
||||||
impl<'t> MakerTrait for Box<Trait<'t>+'static> {
|
impl<'t> MakerTrait for Box<Trait<'t>+'static> {
|
||||||
fn mk() -> Box<Trait<'t>+'static> {
|
fn mk() -> Box<Trait<'t>+'static> {
|
||||||
let tup: Box<(isize, isize)> = box() (4,5);
|
let tup: Box<(isize, isize)> = box (4,5);
|
||||||
tup as Box<Trait>
|
tup as Box<Trait>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,6 +49,6 @@ impl<V> Trait<u8,V> for () {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn main() {
|
pub fn main() {
|
||||||
let a = box() () as Box<Trait<u8, u8>>;
|
let a = box () as Box<Trait<u8, u8>>;
|
||||||
assert_eq!(a.method(Type::Constant((1, 2))), 0);
|
assert_eq!(a.method(Type::Constant((1, 2))), 0);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue