Skip to content

Commit cc09b1a

Browse files
committed
Turn on box(PLACE) expr deprecation warning post-snapshot.
1 parent 5720f70 commit cc09b1a

11 files changed

+20
-13
lines changed

src/liballoc/boxed.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ impl<T: Clone> Clone for Box<T> {
297297
/// let y = x.clone();
298298
/// ```
299299
#[inline]
300-
fn clone(&self) -> Box<T> { box (HEAP) {(**self).clone()} }
300+
fn clone(&self) -> Box<T> { box {(**self).clone()} }
301301
/// Copies `source`'s contents into `self` without creating a new allocation.
302302
///
303303
/// # Examples

src/libsyntax/parse/parser.rs

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2637,19 +2637,15 @@ impl<'a> Parser<'a> {
26372637
//
26382638
// ... but for now: check for a place: `box(PLACE) EXPR`.
26392639

2640-
if try!(self.eat(&token::OpenDelim(token::Paren)) ){
2641-
// SNAP d4432b3
2642-
// Enable this warning after snapshot ...
2643-
//
2644-
// let box_span = mk_sp(lo, self.last_span.hi);
2645-
// self.span_warn(
2646-
// box_span,
2647-
// "deprecated syntax; use the `in` keyword now \
2648-
// (e.g. change `box (<expr>) <expr>` to \
2649-
// `in <expr> { <expr> }`)");
2640+
if try!(self.eat(&token::OpenDelim(token::Paren))) {
2641+
let box_span = mk_sp(lo, self.last_span.hi);
2642+
self.span_warn(box_span,
2643+
"deprecated syntax; use the `in` keyword now \
2644+
(e.g. change `box (<expr>) <expr>` to \
2645+
`in <expr> { <expr> }`)");
26502646

26512647
// Continue supporting `box () EXPR` (temporarily)
2652-
if !try!(self.eat(&token::CloseDelim(token::Paren)) ){
2648+
if !try!(self.eat(&token::CloseDelim(token::Paren))) {
26532649
let place = try!(self.parse_expr_nopanic());
26542650
try!(self.expect(&token::CloseDelim(token::Paren)));
26552651
// Give a suggestion to use `box()` when a parenthesised expression is used

src/test/compile-fail/borrowck-lend-flow-if.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ fn produce<T>() -> T { panic!(); }
2424

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

2930
fn pre_freeze_cond() {

src/test/compile-fail/borrowck-lend-flow-loop.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ fn produce<T>() -> T { panic!(); }
2323

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

2829
fn loop_overarching_alias_mut() {

src/test/compile-fail/borrowck-lend-flow.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ fn produce<T>() -> T { panic!(); }
2424

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

2930
fn pre_freeze() {

src/test/compile-fail/borrowck-loan-in-overloaded-op.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ impl Add for foo {
2323
let foo(box i) = self;
2424
let foo(box j) = f;
2525
foo(box() (i + j))
26+
//~^ WARN deprecated syntax
2627
}
2728
}
2829

src/test/compile-fail/feature-gate-box-expr.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,6 @@ fn main() {
2121
println!("x: {}", x);
2222

2323
let x = box () 'c'; //~ ERROR box expression syntax is experimental
24+
//~^ WARN deprecated syntax
2425
println!("x: {}", x);
2526
}

src/test/compile-fail/feature-gate-placement-expr.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ fn main() {
2020
use std::boxed::HEAP;
2121

2222
let x = box (HEAP) 'c'; //~ ERROR placement-in expression syntax is experimental
23+
//~^ WARN deprecated syntax
2324
println!("x: {}", x);
2425

2526
let x = in HEAP { 'c' }; //~ ERROR placement-in expression syntax is experimental

src/test/compile-fail/issue-14084.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,5 @@ fn main() {
1515
box ( () ) 0;
1616
//~^ ERROR: the trait `core::ops::Placer<_>` is not implemented
1717
//~| ERROR: the trait `core::ops::Placer<_>` is not implemented
18+
//~| WARN deprecated syntax
1819
}

src/test/compile-fail/moves-based-on-type-tuple.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,10 @@
1010

1111
#![feature(box_syntax)]
1212

13-
fn dup(x: Box<isize>) -> Box<(Box<isize>,Box<isize>)> { box() (x, x) } //~ ERROR use of moved value
13+
fn dup(x: Box<isize>) -> Box<(Box<isize>,Box<isize>)> {
14+
box() (x, x) //~ ERROR use of moved value
15+
//~^ WARN deprecated syntax
16+
}
1417
fn main() {
1518
dup(box 3);
1619
}

src/test/parse-fail/parenthesized-box-expr-message.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,6 @@ fn main() {
1414
box (1 + 1)
1515
//~^ HELP try using `box ()` instead:
1616
//~| SUGGESTION box () (1 + 1)
17+
//~| WARN deprecated syntax
1718
; //~ ERROR expected expression, found `;`
1819
}

0 commit comments

Comments
 (0)