Skip to content

Commit

Permalink
Remove even more box syntax uses from src/test
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
est31 committed Aug 7, 2022
1 parent affe0d3 commit 0a03825
Show file tree
Hide file tree
Showing 72 changed files with 154 additions and 212 deletions.
2 changes: 1 addition & 1 deletion src/test/mir-opt/simplify-locals.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// unit-test: SimplifyLocals

#![feature(box_syntax)]

#![feature(thread_local)]

#[derive(Copy, Clone)]
Expand Down
15 changes: 7 additions & 8 deletions src/test/run-make-fulldeps/save-analysis-fail/foo.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#![crate_name = "test"]
#![feature(box_syntax)]
#![feature(rustc_private)]

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

let s: Box<SomeTrait> = box some_fields { field1: 43 };
let s2: Box<some_fields> = box some_fields { field1: 43 };
let s3 = box nofields;
let s: Box<SomeTrait> = Box::new(some_fields { field1: 43 });
let s2: Box<some_fields> = Box::new(some_fields { field1: 43 });
let s3 = Box::new(nofields);

s.Method(43);
s3.Method(43);
Expand Down Expand Up @@ -317,7 +316,7 @@ mod macro_use_test {

fn main() {
// foo
let s = box some_fields { field1: 43 };
let s = Box::new(some_fields { field1: 43 });
hello((43, "a".to_string()), *s);
sub::sub2::hello();
sub2::sub3::hello();
Expand Down Expand Up @@ -345,17 +344,17 @@ fn main() {
let s4: msalias::nested_struct = sub::sub2::nested_struct { field2: 55 };
let s4: msalias::nested_struct = sub2::nested_struct { field2: 55 };
println(&s2.field1.to_string());
let s5: MyType = box some_fields { field1: 55 };
let s5: MyType = Box::new(some_fields { field1: 55 });
let s = SameDir::SameStruct { name: "Bob".to_string() };
let s = SubDir::SubStruct { name: "Bob".to_string() };
let s6: SomeEnum = SomeEnum::MyTypes(box s2.clone(), s5);
let s6: SomeEnum = SomeEnum::MyTypes(Box::new(s2.clone()), s5);
let s7: SomeEnum = SomeEnum::Strings("one", "two", "three");
matchSomeEnum(s6);
matchSomeEnum(s7);
let s8: SomeOtherEnum = SomeOtherEnum::SomeConst2;
matchSomeOtherEnum(s8);
let s9: SomeStructEnum =
SomeStructEnum::EnumStruct2 { f1: box some_fields { field1: 10 }, f2: box s2 };
SomeStructEnum::EnumStruct2 { f1: Box::new(some_fields { field1: 10 }), f2: Box::new(s2) };
matchSomeStructEnum(s9);

for x in &vec![1, 2, 3] {
Expand Down
15 changes: 7 additions & 8 deletions src/test/run-make-fulldeps/save-analysis/foo.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#![crate_name = "test"]
#![feature(box_syntax)]
#![feature(rustc_private)]
#![feature(associated_type_defaults)]

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

let s: Box<SomeTrait> = box some_fields { field1: 43 };
let s2: Box<some_fields> = box some_fields { field1: 43 };
let s3 = box nofields;
let s: Box<SomeTrait> = Box::new(some_fields { field1: 43 });
let s2: Box<some_fields> = Box::new(some_fields { field1: 43 });
let s3 = Box::new(nofields);

s.Method(43);
s3.Method(43);
Expand Down Expand Up @@ -311,7 +310,7 @@ mod macro_use_test {

fn main() {
// foo
let s = box some_fields { field1: 43 };
let s = Box::new(some_fields { field1: 43 });
hello((43, "a".to_string()), *s);
sub::sub2::hello();
sub2::sub3::hello();
Expand Down Expand Up @@ -339,17 +338,17 @@ fn main() {
let s4: msalias::nested_struct = sub::sub2::nested_struct { field2: 55 };
let s4: msalias::nested_struct = sub2::nested_struct { field2: 55 };
println(&s2.field1.to_string());
let s5: MyType = box some_fields { field1: 55 };
let s5: MyType = Box::new(some_fields { field1: 55 });
let s = SameDir::SameStruct { name: "Bob".to_string() };
let s = SubDir::SubStruct { name: "Bob".to_string() };
let s6: SomeEnum = SomeEnum::MyTypes(box s2.clone(), s5);
let s6: SomeEnum = SomeEnum::MyTypes(Box::new(s2.clone()), s5);
let s7: SomeEnum = SomeEnum::Strings("one", "two", "three");
matchSomeEnum(s6);
matchSomeEnum(s7);
let s8: SomeOtherEnum = SomeOtherEnum::SomeConst2;
matchSomeOtherEnum(s8);
let s9: SomeStructEnum =
SomeStructEnum::EnumStruct2 { f1: box some_fields { field1: 10 }, f2: box s2 };
SomeStructEnum::EnumStruct2 { f1: Box::new(some_fields { field1: 10 }), f2: Box::new(s2) };
matchSomeStructEnum(s9);

for x in &vec![1, 2, 3] {
Expand Down
4 changes: 1 addition & 3 deletions src/test/run-pass-valgrind/cleanup-auto-borrow-obj.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
// schedule cleanups when auto borrowing trait objects.
// This program should be valgrind clean.

#![feature(box_syntax)]

static mut DROP_RAN: bool = false;

struct Foo;
Expand All @@ -19,7 +17,7 @@ impl Trait for Foo {}

pub fn main() {
{
let _x: &Trait = &*(box Foo as Box<Trait>);
let _x: &Trait = &*(Box::new(Foo) as Box<Trait>);
}
unsafe {
assert!(DROP_RAN);
Expand Down
15 changes: 9 additions & 6 deletions src/test/run-pass-valgrind/coerce-match.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,18 @@

// pretty-expanded FIXME #23616

#![feature(box_syntax)]

pub fn main() {
let _: Box<[isize]> =
if true { let b: Box<_> = box [1, 2, 3]; b } else { let b: Box<_> = box [1]; b };
let _: Box<[isize]> = if true {
let b: Box<_> = Box::new([1, 2, 3]);
b
} else {
let b: Box<_> = Box::new([1]);
b
};

let _: Box<[isize]> = match true {
true => { let b: Box<_> = box [1, 2, 3]; b }
false => { let b: Box<_> = box [1]; b }
true => { let b: Box<_> = Box::new([1, 2, 3]); b }
false => { let b: Box<_> = Box::new([1]); b }
};

// Check we don't get over-keen at propagating coercions in the case of casts.
Expand Down
4 changes: 2 additions & 2 deletions src/test/rustdoc-ui/rustc-check-passes.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![feature(box_syntax)]
#![feature(box_syntax)] //~ ERROR
#![feature(rustdoc_internals)]
#![feature(rustdoc_internals)] //~ ERROR

pub fn foo() {}
6 changes: 3 additions & 3 deletions src/test/rustdoc-ui/rustc-check-passes.stderr
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
error[E0636]: the feature `box_syntax` has already been declared
error[E0636]: the feature `rustdoc_internals` has already been declared
--> $DIR/rustc-check-passes.rs:2:12
|
LL | #![feature(box_syntax)]
| ^^^^^^^^^^
LL | #![feature(rustdoc_internals)]
| ^^^^^^^^^^^^^^^^^

error: aborting due to previous error

Expand Down
4 changes: 1 addition & 3 deletions src/test/ui/closures/issue-10398.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
#![feature(box_syntax)]

fn main() {
let x: Box<_> = box 1;
let x: Box<_> = Box::new(1);
let f = move|| {
let _a = x;
drop(x);
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/closures/issue-10398.stderr
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error[E0382]: use of moved value: `x`
--> $DIR/issue-10398.rs:7:14
--> $DIR/issue-10398.rs:5:14
|
LL | let _a = x;
| - value moved here
Expand Down
4 changes: 2 additions & 2 deletions src/test/ui/closures/issue-6801.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// transferring ownership of the box before invoking the stack
// closure results in a crash.

#![feature(box_syntax)]


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

fn main() {
let x : Box<usize> = box 9;
let x : Box<usize> = Box::new(9);
let sq = || { *x * *x };

twice(x); //~ ERROR: cannot move out of
Expand Down
6 changes: 2 additions & 4 deletions src/test/ui/dst/dst-rvalue.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
// Check that dynamically sized rvalues are forbidden

#![feature(box_syntax)]

pub fn main() {
let _x: Box<str> = box *"hello world";
let _x: Box<str> = Box::new(*"hello world");
//~^ ERROR E0277

let array: &[isize] = &[1, 2, 3];
let _x: Box<[isize]> = box *array;
let _x: Box<[isize]> = Box::new(*array);
//~^ ERROR E0277
}
28 changes: 20 additions & 8 deletions src/test/ui/dst/dst-rvalue.stderr
Original file line number Diff line number Diff line change
@@ -1,20 +1,32 @@
error[E0277]: the size for values of type `str` cannot be known at compilation time
--> $DIR/dst-rvalue.rs:6:28
--> $DIR/dst-rvalue.rs:4:33
|
LL | let _x: Box<str> = box *"hello world";
| ^^^^^^^^^^^^^^ doesn't have a size known at compile-time
LL | let _x: Box<str> = Box::new(*"hello world");
| -------- ^^^^^^^^^^^^^^ doesn't have a size known at compile-time
| |
| required by a bound introduced by this call
|
= help: the trait `Sized` is not implemented for `str`
= note: the type of a box expression must have a statically known size
note: required by a bound in `Box::<T>::new`
--> $SRC_DIR/alloc/src/boxed.rs:LL:COL
|
LL | impl<T> Box<T> {
| ^ required by this bound in `Box::<T>::new`

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

error: aborting due to 2 previous errors

Expand Down
3 changes: 1 addition & 2 deletions src/test/ui/dynamically-sized-types/dst-struct.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
// run-pass
#![feature(box_syntax)]

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

// Nested Box.
let f1 : Box<Fat<[isize; 3]>> = box Fat { f1: 5, f2: "some str", ptr: [1, 2, 3] };
let f1 : Box<Fat<[isize; 3]>> = Box::new(Fat { f1: 5, f2: "some str", ptr: [1, 2, 3] });
foo(&*f1);
let f2 : Box<Fat<[isize]>> = f1;
foo(&*f2);
Expand Down
1 change: 0 additions & 1 deletion src/test/ui/dynamically-sized-types/dst-trait.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
// run-pass
#![feature(box_syntax)]

struct Fat<T: ?Sized> {
f1: isize,
Expand Down
4 changes: 1 addition & 3 deletions src/test/ui/issues/auxiliary/issue-2380.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
#![crate_name="a"]
#![crate_type = "lib"]

#![feature(box_syntax)]

pub trait i<T>
{
fn dummy(&self, t: T) -> T { panic!() }
Expand All @@ -11,5 +9,5 @@ pub trait i<T>
pub fn f<T>() -> Box<i<T>+'static> {
impl<T> i<T> for () { }

box () as Box<i<T>+'static>
Box::new(()) as Box<i<T>+'static>
}
4 changes: 1 addition & 3 deletions src/test/ui/issues/issue-10682.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,10 @@

// pretty-expanded FIXME #23616

#![feature(box_syntax)]

fn work(_: Box<isize>) {}
fn foo<F:FnOnce()>(_: F) {}

pub fn main() {
let a = box 1;
let a = Box::new(1);
foo(move|| { foo(move|| { work(a) }) })
}
4 changes: 1 addition & 3 deletions src/test/ui/issues/issue-10767.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
// run-pass
// pretty-expanded FIXME #23616

#![feature(box_syntax)]

pub fn main() {
fn f() {
}
let _: Box<fn()> = box (f as fn());
let _: Box<fn()> = Box::new(f as fn());
}
9 changes: 4 additions & 5 deletions src/test/ui/issues/issue-10802.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// run-pass
#![allow(dead_code)]
#![feature(box_syntax)]

struct DroppableStruct;
enum DroppableEnum {
Expand Down Expand Up @@ -33,14 +32,14 @@ impl Whatever {

fn main() {
{
let f: Box<_> = box DroppableStruct;
let _a = Whatever::new(box f as Box<dyn MyTrait>);
let f: Box<_> = Box::new(DroppableStruct);
let _a = Whatever::new(Box::new(f) as Box<dyn MyTrait>);
}
assert!(unsafe { DROPPED });
unsafe { DROPPED = false; }
{
let f: Box<_> = box DroppableEnum::DroppableVariant1;
let _a = Whatever::new(box f as Box<dyn MyTrait>);
let f: Box<_> = Box::new(DroppableEnum::DroppableVariant1);
let _a = Whatever::new(Box::new(f) as Box<dyn MyTrait>);
}
assert!(unsafe { DROPPED });
}
8 changes: 4 additions & 4 deletions src/test/ui/issues/issue-11192.rs
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
#![feature(box_syntax)]

struct Foo {
x: isize
}


impl Drop for Foo {
fn drop(&mut self) {
println!("drop {}", self.x);
}
}


fn main() {
let mut ptr: Box<_> = box Foo { x: 0 };
let mut ptr: Box<_> = Box::new(Foo { x: 0 });
let mut test = |foo: &Foo| {
println!("access {}", foo.x);
ptr = box Foo { x: ptr.x + 1 };
ptr = Box::new(Foo { x: ptr.x + 1 });
println!("access {}", foo.x);
};
test(&*ptr);
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/issues/issue-11192.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ error[E0502]: cannot borrow `*ptr` as immutable because it is also borrowed as m
LL | let mut test = |foo: &Foo| {
| ----------- mutable borrow occurs here
LL | println!("access {}", foo.x);
LL | ptr = box Foo { x: ptr.x + 1 };
LL | ptr = Box::new(Foo { x: ptr.x + 1 });
| --- first borrow occurs due to use of `ptr` in closure
...
LL | test(&*ptr);
Expand Down
6 changes: 3 additions & 3 deletions src/test/ui/issues/issue-11515.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#![feature(box_syntax)]

struct Test {
func: Box<dyn FnMut() + 'static>,
}



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

0 comments on commit 0a03825

Please sign in to comment.