summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorclubby789 <jamie@hill-daniel.co.uk>2023-02-27 13:22:43 +0000
committerclubby789 <jamie@hill-daniel.co.uk>2023-03-12 13:26:37 +0000
commit8b186dfdb70ebfe722975970458c6230841e6911 (patch)
treeff456dece9e8fb66885138e7405725f6950b75e6 /tests
parenta8d5950b4db8feddff469d6c35a8f29f485ce951 (diff)
downloadrust-8b186dfdb70ebfe722975970458c6230841e6911.tar.gz
Add recovery for use of removed `box` syntax
Diffstat (limited to 'tests')
-rw-r--r--tests/ui/parser/removed-syntax-box.fixed14
-rw-r--r--tests/ui/parser/removed-syntax-box.rs12
-rw-r--r--tests/ui/parser/removed-syntax-box.stderr59
-rw-r--r--tests/ui/unpretty/box.stdout2
4 files changed, 77 insertions, 10 deletions
diff --git a/tests/ui/parser/removed-syntax-box.fixed b/tests/ui/parser/removed-syntax-box.fixed
new file mode 100644
index 00000000000..09d1304b775
--- /dev/null
+++ b/tests/ui/parser/removed-syntax-box.fixed
@@ -0,0 +1,14 @@
+// run-rustfix
+
+fn main() {
+ #[allow(dead_code)]
+ struct T {
+ a: u8,
+ b: u8,
+ }
+ let _ = Box::new(()); //~ ERROR `box_syntax` has been removed
+ let _ = Box::new(1); //~ ERROR `box_syntax` has been removed
+ let _ = Box::new(T { a: 12, b: 18 }); //~ ERROR `box_syntax` has been removed
+ let _ = Box::new([5; 30]); //~ ERROR `box_syntax` has been removed
+ let _: Box<()> = Box::new(()); //~ ERROR `box_syntax` has been removed
+}
diff --git a/tests/ui/parser/removed-syntax-box.rs b/tests/ui/parser/removed-syntax-box.rs
index b0e8eb0410e..1f5061b02c7 100644
--- a/tests/ui/parser/removed-syntax-box.rs
+++ b/tests/ui/parser/removed-syntax-box.rs
@@ -1,10 +1,14 @@
+// run-rustfix
+
fn main() {
+ #[allow(dead_code)]
struct T {
a: u8,
b: u8,
}
- let _ = box () //~ ERROR expected expression, found reserved keyword `box`
- let _ = box 1;
- let _ = box T { a: 12, b: 18 };
- let _ = box [5; 30];
+ let _ = box (); //~ ERROR `box_syntax` has been removed
+ let _ = box 1; //~ ERROR `box_syntax` has been removed
+ let _ = box T { a: 12, b: 18 }; //~ ERROR `box_syntax` has been removed
+ let _ = box [5; 30]; //~ ERROR `box_syntax` has been removed
+ let _: Box<()> = box (); //~ ERROR `box_syntax` has been removed
}
diff --git a/tests/ui/parser/removed-syntax-box.stderr b/tests/ui/parser/removed-syntax-box.stderr
index 8c8d5b3c4cb..46b891587d5 100644
--- a/tests/ui/parser/removed-syntax-box.stderr
+++ b/tests/ui/parser/removed-syntax-box.stderr
@@ -1,8 +1,57 @@
-error: expected expression, found reserved keyword `box`
- --> $DIR/removed-syntax-box.rs:6:13
+error: `box_syntax` has been removed
+ --> $DIR/removed-syntax-box.rs:9:13
|
-LL | let _ = box ()
- | ^^^ expected expression
+LL | let _ = box ();
+ | ^^^^^^
+ |
+help: use `Box::new()` instead
+ |
+LL | let _ = Box::new(());
+ | ~~~~~~~~~~~~
+
+error: `box_syntax` has been removed
+ --> $DIR/removed-syntax-box.rs:10:13
+ |
+LL | let _ = box 1;
+ | ^^^^^
+ |
+help: use `Box::new()` instead
+ |
+LL | let _ = Box::new(1);
+ | ~~~~~~~~~~~
+
+error: `box_syntax` has been removed
+ --> $DIR/removed-syntax-box.rs:11:13
+ |
+LL | let _ = box T { a: 12, b: 18 };
+ | ^^^^^^^^^^^^^^^^^^^^^^
+ |
+help: use `Box::new()` instead
+ |
+LL | let _ = Box::new(T { a: 12, b: 18 });
+ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+error: `box_syntax` has been removed
+ --> $DIR/removed-syntax-box.rs:12:13
+ |
+LL | let _ = box [5; 30];
+ | ^^^^^^^^^^^
+ |
+help: use `Box::new()` instead
+ |
+LL | let _ = Box::new([5; 30]);
+ | ~~~~~~~~~~~~~~~~~
+
+error: `box_syntax` has been removed
+ --> $DIR/removed-syntax-box.rs:13:22
+ |
+LL | let _: Box<()> = box ();
+ | ^^^^^^
+ |
+help: use `Box::new()` instead
+ |
+LL | let _: Box<()> = Box::new(());
+ | ~~~~~~~~~~~~
-error: aborting due to previous error
+error: aborting due to 5 previous errors
diff --git a/tests/ui/unpretty/box.stdout b/tests/ui/unpretty/box.stdout
index 1318a56e3be..0c6e012e698 100644
--- a/tests/ui/unpretty/box.stdout
+++ b/tests/ui/unpretty/box.stdout
@@ -10,5 +10,5 @@ extern crate std;
fn main() {
let _ =
#[rustc_box]
- Box::new (1);
+ Box::new(1);
}