Skip to content

Commit

Permalink
Turn on box(PLACE) expr deprecation warning post-snapshot.
Browse files Browse the repository at this point in the history
  • Loading branch information
eddyb committed Jul 27, 2015
1 parent 5720f70 commit cc09b1a
Show file tree
Hide file tree
Showing 11 changed files with 20 additions and 13 deletions.
2 changes: 1 addition & 1 deletion src/liballoc/boxed.rs
Expand Up @@ -297,7 +297,7 @@ impl<T: Clone> Clone for Box<T> {
/// let y = x.clone();
/// ```
#[inline]
fn clone(&self) -> Box<T> { box (HEAP) {(**self).clone()} }
fn clone(&self) -> Box<T> { box {(**self).clone()} }
/// Copies `source`'s contents into `self` without creating a new allocation.
///
/// # Examples
Expand Down
18 changes: 7 additions & 11 deletions src/libsyntax/parse/parser.rs
Expand Up @@ -2637,19 +2637,15 @@ impl<'a> Parser<'a> {
//
// ... but for now: check for a place: `box(PLACE) EXPR`.

if try!(self.eat(&token::OpenDelim(token::Paren)) ){
// SNAP d4432b3
// Enable this warning after snapshot ...
//
// 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> }`)");
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)) ){
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
Expand Down
1 change: 1 addition & 0 deletions src/test/compile-fail/borrowck-lend-flow-if.rs
Expand Up @@ -24,6 +24,7 @@ fn produce<T>() -> T { panic!(); }

fn inc(v: &mut Box<isize>) {
*v = box() (**v + 1);
//~^ WARN deprecated syntax
}

fn pre_freeze_cond() {
Expand Down
1 change: 1 addition & 0 deletions src/test/compile-fail/borrowck-lend-flow-loop.rs
Expand Up @@ -23,6 +23,7 @@ fn produce<T>() -> T { panic!(); }

fn inc(v: &mut Box<isize>) {
*v = box() (**v + 1);
//~^ WARN deprecated syntax
}

fn loop_overarching_alias_mut() {
Expand Down
1 change: 1 addition & 0 deletions src/test/compile-fail/borrowck-lend-flow.rs
Expand Up @@ -24,6 +24,7 @@ fn produce<T>() -> T { panic!(); }

fn inc(v: &mut Box<isize>) {
*v = box() (**v + 1);
//~^ WARN deprecated syntax
}

fn pre_freeze() {
Expand Down
1 change: 1 addition & 0 deletions src/test/compile-fail/borrowck-loan-in-overloaded-op.rs
Expand Up @@ -23,6 +23,7 @@ impl Add for foo {
let foo(box i) = self;
let foo(box j) = f;
foo(box() (i + j))
//~^ WARN deprecated syntax
}
}

Expand Down
1 change: 1 addition & 0 deletions src/test/compile-fail/feature-gate-box-expr.rs
Expand Up @@ -21,5 +21,6 @@ fn main() {
println!("x: {}", x);

let x = box () 'c'; //~ ERROR box expression syntax is experimental
//~^ WARN deprecated syntax
println!("x: {}", x);
}
1 change: 1 addition & 0 deletions src/test/compile-fail/feature-gate-placement-expr.rs
Expand Up @@ -20,6 +20,7 @@ fn main() {
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
Expand Down
1 change: 1 addition & 0 deletions src/test/compile-fail/issue-14084.rs
Expand Up @@ -15,4 +15,5 @@ fn main() {
box ( () ) 0;
//~^ ERROR: the trait `core::ops::Placer<_>` is not implemented
//~| ERROR: the trait `core::ops::Placer<_>` is not implemented
//~| WARN deprecated syntax
}
5 changes: 4 additions & 1 deletion src/test/compile-fail/moves-based-on-type-tuple.rs
Expand Up @@ -10,7 +10,10 @@

#![feature(box_syntax)]

fn dup(x: Box<isize>) -> Box<(Box<isize>,Box<isize>)> { box() (x, x) } //~ ERROR use of moved value
fn dup(x: Box<isize>) -> Box<(Box<isize>,Box<isize>)> {
box() (x, x) //~ ERROR use of moved value
//~^ WARN deprecated syntax
}
fn main() {
dup(box 3);
}
1 change: 1 addition & 0 deletions src/test/parse-fail/parenthesized-box-expr-message.rs
Expand Up @@ -14,5 +14,6 @@ fn main() {
box (1 + 1)
//~^ HELP try using `box ()` instead:
//~| SUGGESTION box () (1 + 1)
//~| WARN deprecated syntax
; //~ ERROR expected expression, found `;`
}

0 comments on commit cc09b1a

Please sign in to comment.