about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--src/test/ui/dst/dst-rvalue.rs6
-rw-r--r--src/test/ui/dst/dst-rvalue.stderr34
-rw-r--r--src/test/ui/typeck/issue-87935-unsized-box-expr.rs10
-rw-r--r--src/test/ui/typeck/issue-87935-unsized-box-expr.stderr12
4 files changed, 36 insertions, 26 deletions
diff --git a/src/test/ui/dst/dst-rvalue.rs b/src/test/ui/dst/dst-rvalue.rs
index aa028396be4..b52a95a701f 100644
--- a/src/test/ui/dst/dst-rvalue.rs
+++ b/src/test/ui/dst/dst-rvalue.rs
@@ -4,11 +4,9 @@
 
 pub fn main() {
     let _x: Box<str> = box *"hello world";
-    //~^ ERROR E0161
-    //~^^ ERROR cannot move out of a shared reference
+    //~^ ERROR E0277
 
     let array: &[isize] = &[1, 2, 3];
     let _x: Box<[isize]> = box *array;
-    //~^ ERROR E0161
-    //~^^ ERROR cannot move out of type `[isize]`, a non-copy slice
+    //~^ ERROR E0277
 }
diff --git a/src/test/ui/dst/dst-rvalue.stderr b/src/test/ui/dst/dst-rvalue.stderr
index 6a51c517558..15830636b51 100644
--- a/src/test/ui/dst/dst-rvalue.stderr
+++ b/src/test/ui/dst/dst-rvalue.stderr
@@ -1,31 +1,21 @@
-error[E0161]: cannot move a value of type str: the size of str cannot be statically determined
+error[E0277]: the size for values of type `str` cannot be known at compilation time
   --> $DIR/dst-rvalue.rs:6:28
    |
 LL |     let _x: Box<str> = box *"hello world";
-   |                            ^^^^^^^^^^^^^^
-
-error[E0161]: cannot move a value of type [isize]: the size of [isize] cannot be statically determined
-  --> $DIR/dst-rvalue.rs:11:32
+   |                            ^^^^^^^^^^^^^^ doesn't have a size known at compile-time
    |
-LL |     let _x: Box<[isize]> = box *array;
-   |                                ^^^^^^
+   = help: the trait `Sized` is not implemented for `str`
+   = note: the type of a box expression must have a statically known size
 
-error[E0507]: cannot move out of a shared reference
-  --> $DIR/dst-rvalue.rs:6:28
-   |
-LL |     let _x: Box<str> = box *"hello world";
-   |                            ^^^^^^^^^^^^^^ move occurs because value has type `str`, which does not implement the `Copy` trait
-
-error[E0508]: cannot move out of type `[isize]`, a non-copy slice
-  --> $DIR/dst-rvalue.rs:11:32
+error[E0277]: the size for values of type `[isize]` cannot be known at compilation time
+  --> $DIR/dst-rvalue.rs:10:32
    |
 LL |     let _x: Box<[isize]> = box *array;
-   |                                ^^^^^^
-   |                                |
-   |                                cannot move out of here
-   |                                move occurs because `*array` has type `[isize]`, which does not implement the `Copy` trait
+   |                                ^^^^^^ doesn't have a size known at compile-time
+   |
+   = help: the trait `Sized` is not implemented for `[isize]`
+   = note: the type of a box expression must have a statically known size
 
-error: aborting due to 4 previous errors
+error: aborting due to 2 previous errors
 
-Some errors have detailed explanations: E0161, E0507, E0508.
-For more information about an error, try `rustc --explain E0161`.
+For more information about this error, try `rustc --explain E0277`.
diff --git a/src/test/ui/typeck/issue-87935-unsized-box-expr.rs b/src/test/ui/typeck/issue-87935-unsized-box-expr.rs
new file mode 100644
index 00000000000..cd2a82074ed
--- /dev/null
+++ b/src/test/ui/typeck/issue-87935-unsized-box-expr.rs
@@ -0,0 +1,10 @@
+#![feature(box_syntax)]
+// Box expression needs to be movable, and hence has to be of a Sized type.
+fn main() {
+    let _x: Box<[u32]> = box { loop {} };
+    //~^ ERROR: the size for values of type `[u32]` cannot be known at compilation time
+
+    // Check that a deduced size does not cause issues.
+    let _y: Box<[u32]> = box [];
+    let _z: Box<[u32; 0]> = box { loop {} };
+}
diff --git a/src/test/ui/typeck/issue-87935-unsized-box-expr.stderr b/src/test/ui/typeck/issue-87935-unsized-box-expr.stderr
new file mode 100644
index 00000000000..9ff822352a1
--- /dev/null
+++ b/src/test/ui/typeck/issue-87935-unsized-box-expr.stderr
@@ -0,0 +1,12 @@
+error[E0277]: the size for values of type `[u32]` cannot be known at compilation time
+  --> $DIR/issue-87935-unsized-box-expr.rs:4:30
+   |
+LL |     let _x: Box<[u32]> = box { loop {} };
+   |                              ^^^^^^^^^^^ doesn't have a size known at compile-time
+   |
+   = help: the trait `Sized` is not implemented for `[u32]`
+   = note: the type of a box expression must have a statically known size
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0277`.