Skip to content

Commit 0a03825

Browse files
committed
Remove even more box syntax uses from src/test
Prior work, notably 6550021 from #88316 has removed box syntax from most of the testsuite. However, some tests were left out. This commit removes box_syntax uses from more locations in src/test. Some tests that are very box syntax specific are not being migrated.
1 parent affe0d3 commit 0a03825

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

72 files changed

+154
-212
lines changed

src/test/mir-opt/simplify-locals.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// unit-test: SimplifyLocals
22

3-
#![feature(box_syntax)]
3+
44
#![feature(thread_local)]
55

66
#[derive(Copy, Clone)]

src/test/run-make-fulldeps/save-analysis-fail/foo.rs

+7-8
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#![crate_name = "test"]
2-
#![feature(box_syntax)]
32
#![feature(rustc_private)]
43

54
extern crate rustc_graphviz;
@@ -261,9 +260,9 @@ fn hello<X: SomeTrait>((z, a): (u32, String), ex: X) {
261260
let x = 32.0f32;
262261
let _ = (x + ((x * x) + 1.0).sqrt()).ln();
263262

264-
let s: Box<SomeTrait> = box some_fields { field1: 43 };
265-
let s2: Box<some_fields> = box some_fields { field1: 43 };
266-
let s3 = box nofields;
263+
let s: Box<SomeTrait> = Box::new(some_fields { field1: 43 });
264+
let s2: Box<some_fields> = Box::new(some_fields { field1: 43 });
265+
let s3 = Box::new(nofields);
267266

268267
s.Method(43);
269268
s3.Method(43);
@@ -317,7 +316,7 @@ mod macro_use_test {
317316

318317
fn main() {
319318
// foo
320-
let s = box some_fields { field1: 43 };
319+
let s = Box::new(some_fields { field1: 43 });
321320
hello((43, "a".to_string()), *s);
322321
sub::sub2::hello();
323322
sub2::sub3::hello();
@@ -345,17 +344,17 @@ fn main() {
345344
let s4: msalias::nested_struct = sub::sub2::nested_struct { field2: 55 };
346345
let s4: msalias::nested_struct = sub2::nested_struct { field2: 55 };
347346
println(&s2.field1.to_string());
348-
let s5: MyType = box some_fields { field1: 55 };
347+
let s5: MyType = Box::new(some_fields { field1: 55 });
349348
let s = SameDir::SameStruct { name: "Bob".to_string() };
350349
let s = SubDir::SubStruct { name: "Bob".to_string() };
351-
let s6: SomeEnum = SomeEnum::MyTypes(box s2.clone(), s5);
350+
let s6: SomeEnum = SomeEnum::MyTypes(Box::new(s2.clone()), s5);
352351
let s7: SomeEnum = SomeEnum::Strings("one", "two", "three");
353352
matchSomeEnum(s6);
354353
matchSomeEnum(s7);
355354
let s8: SomeOtherEnum = SomeOtherEnum::SomeConst2;
356355
matchSomeOtherEnum(s8);
357356
let s9: SomeStructEnum =
358-
SomeStructEnum::EnumStruct2 { f1: box some_fields { field1: 10 }, f2: box s2 };
357+
SomeStructEnum::EnumStruct2 { f1: Box::new(some_fields { field1: 10 }), f2: Box::new(s2) };
359358
matchSomeStructEnum(s9);
360359

361360
for x in &vec![1, 2, 3] {

src/test/run-make-fulldeps/save-analysis/foo.rs

+7-8
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#![crate_name = "test"]
2-
#![feature(box_syntax)]
32
#![feature(rustc_private)]
43
#![feature(associated_type_defaults)]
54

@@ -255,9 +254,9 @@ fn hello<X: SomeTrait>((z, a): (u32, String), ex: X) {
255254
let x = 32.0f32;
256255
let _ = (x + ((x * x) + 1.0).sqrt()).ln();
257256

258-
let s: Box<SomeTrait> = box some_fields { field1: 43 };
259-
let s2: Box<some_fields> = box some_fields { field1: 43 };
260-
let s3 = box nofields;
257+
let s: Box<SomeTrait> = Box::new(some_fields { field1: 43 });
258+
let s2: Box<some_fields> = Box::new(some_fields { field1: 43 });
259+
let s3 = Box::new(nofields);
261260

262261
s.Method(43);
263262
s3.Method(43);
@@ -311,7 +310,7 @@ mod macro_use_test {
311310

312311
fn main() {
313312
// foo
314-
let s = box some_fields { field1: 43 };
313+
let s = Box::new(some_fields { field1: 43 });
315314
hello((43, "a".to_string()), *s);
316315
sub::sub2::hello();
317316
sub2::sub3::hello();
@@ -339,17 +338,17 @@ fn main() {
339338
let s4: msalias::nested_struct = sub::sub2::nested_struct { field2: 55 };
340339
let s4: msalias::nested_struct = sub2::nested_struct { field2: 55 };
341340
println(&s2.field1.to_string());
342-
let s5: MyType = box some_fields { field1: 55 };
341+
let s5: MyType = Box::new(some_fields { field1: 55 });
343342
let s = SameDir::SameStruct { name: "Bob".to_string() };
344343
let s = SubDir::SubStruct { name: "Bob".to_string() };
345-
let s6: SomeEnum = SomeEnum::MyTypes(box s2.clone(), s5);
344+
let s6: SomeEnum = SomeEnum::MyTypes(Box::new(s2.clone()), s5);
346345
let s7: SomeEnum = SomeEnum::Strings("one", "two", "three");
347346
matchSomeEnum(s6);
348347
matchSomeEnum(s7);
349348
let s8: SomeOtherEnum = SomeOtherEnum::SomeConst2;
350349
matchSomeOtherEnum(s8);
351350
let s9: SomeStructEnum =
352-
SomeStructEnum::EnumStruct2 { f1: box some_fields { field1: 10 }, f2: box s2 };
351+
SomeStructEnum::EnumStruct2 { f1: Box::new(some_fields { field1: 10 }), f2: Box::new(s2) };
353352
matchSomeStructEnum(s9);
354353

355354
for x in &vec![1, 2, 3] {

src/test/run-pass-valgrind/cleanup-auto-borrow-obj.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
// schedule cleanups when auto borrowing trait objects.
33
// This program should be valgrind clean.
44

5-
#![feature(box_syntax)]
6-
75
static mut DROP_RAN: bool = false;
86

97
struct Foo;
@@ -19,7 +17,7 @@ impl Trait for Foo {}
1917

2018
pub fn main() {
2119
{
22-
let _x: &Trait = &*(box Foo as Box<Trait>);
20+
let _x: &Trait = &*(Box::new(Foo) as Box<Trait>);
2321
}
2422
unsafe {
2523
assert!(DROP_RAN);

src/test/run-pass-valgrind/coerce-match.rs

+9-6
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,18 @@
22

33
// pretty-expanded FIXME #23616
44

5-
#![feature(box_syntax)]
6-
75
pub fn main() {
8-
let _: Box<[isize]> =
9-
if true { let b: Box<_> = box [1, 2, 3]; b } else { let b: Box<_> = box [1]; b };
6+
let _: Box<[isize]> = if true {
7+
let b: Box<_> = Box::new([1, 2, 3]);
8+
b
9+
} else {
10+
let b: Box<_> = Box::new([1]);
11+
b
12+
};
1013

1114
let _: Box<[isize]> = match true {
12-
true => { let b: Box<_> = box [1, 2, 3]; b }
13-
false => { let b: Box<_> = box [1]; b }
15+
true => { let b: Box<_> = Box::new([1, 2, 3]); b }
16+
false => { let b: Box<_> = Box::new([1]); b }
1417
};
1518

1619
// Check we don't get over-keen at propagating coercions in the case of casts.
+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#![feature(box_syntax)]
2-
#![feature(box_syntax)] //~ ERROR
1+
#![feature(rustdoc_internals)]
2+
#![feature(rustdoc_internals)] //~ ERROR
33

44
pub fn foo() {}

src/test/rustdoc-ui/rustc-check-passes.stderr

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
error[E0636]: the feature `box_syntax` has already been declared
1+
error[E0636]: the feature `rustdoc_internals` has already been declared
22
--> $DIR/rustc-check-passes.rs:2:12
33
|
4-
LL | #![feature(box_syntax)]
5-
| ^^^^^^^^^^
4+
LL | #![feature(rustdoc_internals)]
5+
| ^^^^^^^^^^^^^^^^^
66

77
error: aborting due to previous error
88

src/test/ui/closures/issue-10398.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
1-
#![feature(box_syntax)]
2-
31
fn main() {
4-
let x: Box<_> = box 1;
2+
let x: Box<_> = Box::new(1);
53
let f = move|| {
64
let _a = x;
75
drop(x);

src/test/ui/closures/issue-10398.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0382]: use of moved value: `x`
2-
--> $DIR/issue-10398.rs:7:14
2+
--> $DIR/issue-10398.rs:5:14
33
|
44
LL | let _a = x;
55
| - value moved here

src/test/ui/closures/issue-6801.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// transferring ownership of the box before invoking the stack
33
// closure results in a crash.
44

5-
#![feature(box_syntax)]
5+
66

77
fn twice(x: Box<usize>) -> usize {
88
*x * 2
@@ -13,7 +13,7 @@ fn invoke<F>(f: F) where F: FnOnce() -> usize {
1313
}
1414

1515
fn main() {
16-
let x : Box<usize> = box 9;
16+
let x : Box<usize> = Box::new(9);
1717
let sq = || { *x * *x };
1818

1919
twice(x); //~ ERROR: cannot move out of

src/test/ui/dst/dst-rvalue.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
// Check that dynamically sized rvalues are forbidden
22

3-
#![feature(box_syntax)]
4-
53
pub fn main() {
6-
let _x: Box<str> = box *"hello world";
4+
let _x: Box<str> = Box::new(*"hello world");
75
//~^ ERROR E0277
86

97
let array: &[isize] = &[1, 2, 3];
10-
let _x: Box<[isize]> = box *array;
8+
let _x: Box<[isize]> = Box::new(*array);
119
//~^ ERROR E0277
1210
}

src/test/ui/dst/dst-rvalue.stderr

+20-8
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,32 @@
11
error[E0277]: the size for values of type `str` cannot be known at compilation time
2-
--> $DIR/dst-rvalue.rs:6:28
2+
--> $DIR/dst-rvalue.rs:4:33
33
|
4-
LL | let _x: Box<str> = box *"hello world";
5-
| ^^^^^^^^^^^^^^ doesn't have a size known at compile-time
4+
LL | let _x: Box<str> = Box::new(*"hello world");
5+
| -------- ^^^^^^^^^^^^^^ doesn't have a size known at compile-time
6+
| |
7+
| required by a bound introduced by this call
68
|
79
= help: the trait `Sized` is not implemented for `str`
8-
= note: the type of a box expression must have a statically known size
10+
note: required by a bound in `Box::<T>::new`
11+
--> $SRC_DIR/alloc/src/boxed.rs:LL:COL
12+
|
13+
LL | impl<T> Box<T> {
14+
| ^ required by this bound in `Box::<T>::new`
915

1016
error[E0277]: the size for values of type `[isize]` cannot be known at compilation time
11-
--> $DIR/dst-rvalue.rs:10:32
17+
--> $DIR/dst-rvalue.rs:8:37
1218
|
13-
LL | let _x: Box<[isize]> = box *array;
14-
| ^^^^^^ doesn't have a size known at compile-time
19+
LL | let _x: Box<[isize]> = Box::new(*array);
20+
| -------- ^^^^^^ doesn't have a size known at compile-time
21+
| |
22+
| required by a bound introduced by this call
1523
|
1624
= help: the trait `Sized` is not implemented for `[isize]`
17-
= note: the type of a box expression must have a statically known size
25+
note: required by a bound in `Box::<T>::new`
26+
--> $SRC_DIR/alloc/src/boxed.rs:LL:COL
27+
|
28+
LL | impl<T> Box<T> {
29+
| ^ required by this bound in `Box::<T>::new`
1830

1931
error: aborting due to 2 previous errors
2032

src/test/ui/dynamically-sized-types/dst-struct.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
// run-pass
2-
#![feature(box_syntax)]
32

43
struct Fat<T: ?Sized> {
54
f1: isize,
@@ -111,7 +110,7 @@ pub fn main() {
111110
assert_eq!((*f2)[1], 2);
112111

113112
// Nested Box.
114-
let f1 : Box<Fat<[isize; 3]>> = box Fat { f1: 5, f2: "some str", ptr: [1, 2, 3] };
113+
let f1 : Box<Fat<[isize; 3]>> = Box::new(Fat { f1: 5, f2: "some str", ptr: [1, 2, 3] });
115114
foo(&*f1);
116115
let f2 : Box<Fat<[isize]>> = f1;
117116
foo(&*f2);

src/test/ui/dynamically-sized-types/dst-trait.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
// run-pass
2-
#![feature(box_syntax)]
32

43
struct Fat<T: ?Sized> {
54
f1: isize,
+1-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
#![crate_name="a"]
22
#![crate_type = "lib"]
33

4-
#![feature(box_syntax)]
5-
64
pub trait i<T>
75
{
86
fn dummy(&self, t: T) -> T { panic!() }
@@ -11,5 +9,5 @@ pub trait i<T>
119
pub fn f<T>() -> Box<i<T>+'static> {
1210
impl<T> i<T> for () { }
1311

14-
box () as Box<i<T>+'static>
12+
Box::new(()) as Box<i<T>+'static>
1513
}

src/test/ui/issues/issue-10682.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,10 @@
44

55
// pretty-expanded FIXME #23616
66

7-
#![feature(box_syntax)]
8-
97
fn work(_: Box<isize>) {}
108
fn foo<F:FnOnce()>(_: F) {}
119

1210
pub fn main() {
13-
let a = box 1;
11+
let a = Box::new(1);
1412
foo(move|| { foo(move|| { work(a) }) })
1513
}

src/test/ui/issues/issue-10767.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
// run-pass
22
// pretty-expanded FIXME #23616
33

4-
#![feature(box_syntax)]
5-
64
pub fn main() {
75
fn f() {
86
}
9-
let _: Box<fn()> = box (f as fn());
7+
let _: Box<fn()> = Box::new(f as fn());
108
}

src/test/ui/issues/issue-10802.rs

+4-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
// run-pass
22
#![allow(dead_code)]
3-
#![feature(box_syntax)]
43

54
struct DroppableStruct;
65
enum DroppableEnum {
@@ -33,14 +32,14 @@ impl Whatever {
3332

3433
fn main() {
3534
{
36-
let f: Box<_> = box DroppableStruct;
37-
let _a = Whatever::new(box f as Box<dyn MyTrait>);
35+
let f: Box<_> = Box::new(DroppableStruct);
36+
let _a = Whatever::new(Box::new(f) as Box<dyn MyTrait>);
3837
}
3938
assert!(unsafe { DROPPED });
4039
unsafe { DROPPED = false; }
4140
{
42-
let f: Box<_> = box DroppableEnum::DroppableVariant1;
43-
let _a = Whatever::new(box f as Box<dyn MyTrait>);
41+
let f: Box<_> = Box::new(DroppableEnum::DroppableVariant1);
42+
let _a = Whatever::new(Box::new(f) as Box<dyn MyTrait>);
4443
}
4544
assert!(unsafe { DROPPED });
4645
}

src/test/ui/issues/issue-11192.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
1-
#![feature(box_syntax)]
2-
31
struct Foo {
42
x: isize
53
}
64

5+
76
impl Drop for Foo {
87
fn drop(&mut self) {
98
println!("drop {}", self.x);
109
}
1110
}
1211

12+
1313
fn main() {
14-
let mut ptr: Box<_> = box Foo { x: 0 };
14+
let mut ptr: Box<_> = Box::new(Foo { x: 0 });
1515
let mut test = |foo: &Foo| {
1616
println!("access {}", foo.x);
17-
ptr = box Foo { x: ptr.x + 1 };
17+
ptr = Box::new(Foo { x: ptr.x + 1 });
1818
println!("access {}", foo.x);
1919
};
2020
test(&*ptr);

src/test/ui/issues/issue-11192.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ error[E0502]: cannot borrow `*ptr` as immutable because it is also borrowed as m
44
LL | let mut test = |foo: &Foo| {
55
| ----------- mutable borrow occurs here
66
LL | println!("access {}", foo.x);
7-
LL | ptr = box Foo { x: ptr.x + 1 };
7+
LL | ptr = Box::new(Foo { x: ptr.x + 1 });
88
| --- first borrow occurs due to use of `ptr` in closure
99
...
1010
LL | test(&*ptr);

src/test/ui/issues/issue-11515.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
#![feature(box_syntax)]
2-
31
struct Test {
42
func: Box<dyn FnMut() + 'static>,
53
}
64

5+
6+
77
fn main() {
88
let closure: Box<dyn Fn() + 'static> = Box::new(|| ());
9-
let test = box Test { func: closure }; //~ ERROR trait upcasting coercion is experimental [E0658]
9+
let test = Box::new(Test { func: closure }); //~ ERROR trait upcasting coercion is experimental [E0658]
1010
}

0 commit comments

Comments
 (0)