about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMasaki Hara <ackie.h.gmai@gmail.com>2018-11-19 00:19:14 +0900
committerMasaki Hara <ackie.h.gmai@gmail.com>2018-11-21 22:20:22 +0900
commit8ab5be13a31261317c0e4b52bd4743da03e5bf74 (patch)
tree2a1bfe8e5ae051cd3b891ad3857fc6d5a2e1f35a
parent8b426232eef0629265bbfd0bc81fab75e113762b (diff)
downloadrust-8ab5be13a31261317c0e4b52bd4743da03e5bf74.tar.gz
rust-8ab5be13a31261317c0e4b52bd4743da03e5bf74.zip
Add tests verifying #50940.
-rw-r--r--src/test/ui/unsized-locals/issue-50940-with-feature.rs7
-rw-r--r--src/test/ui/unsized-locals/issue-50940-with-feature.stderr14
-rw-r--r--src/test/ui/unsized-locals/issue-50940.rs5
-rw-r--r--src/test/ui/unsized-locals/issue-50940.stderr14
4 files changed, 40 insertions, 0 deletions
diff --git a/src/test/ui/unsized-locals/issue-50940-with-feature.rs b/src/test/ui/unsized-locals/issue-50940-with-feature.rs
new file mode 100644
index 00000000000..3e5d39ab311
--- /dev/null
+++ b/src/test/ui/unsized-locals/issue-50940-with-feature.rs
@@ -0,0 +1,7 @@
+#![feature(unsized_locals)]
+
+fn main() {
+    struct A<X: ?Sized>(X);
+    A as fn(str) -> A<str>;
+    //~^ERROR the size for values of type `str` cannot be known at compilation time
+}
diff --git a/src/test/ui/unsized-locals/issue-50940-with-feature.stderr b/src/test/ui/unsized-locals/issue-50940-with-feature.stderr
new file mode 100644
index 00000000000..f4f015fa190
--- /dev/null
+++ b/src/test/ui/unsized-locals/issue-50940-with-feature.stderr
@@ -0,0 +1,14 @@
+error[E0277]: the size for values of type `str` cannot be known at compilation time
+  --> $DIR/issue-50940-with-feature.rs:5:5
+   |
+LL |     A as fn(str) -> A<str>;
+   |     ^ doesn't have a size known at compile-time
+   |
+   = help: within `main::A<str>`, the trait `std::marker::Sized` is not implemented for `str`
+   = note: to learn more, visit <https://doc.rust-lang.org/book/second-edition/ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait>
+   = note: required because it appears within the type `main::A<str>`
+   = note: the return type of a function must have a statically known size
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0277`.
diff --git a/src/test/ui/unsized-locals/issue-50940.rs b/src/test/ui/unsized-locals/issue-50940.rs
new file mode 100644
index 00000000000..7ba809b7e83
--- /dev/null
+++ b/src/test/ui/unsized-locals/issue-50940.rs
@@ -0,0 +1,5 @@
+fn main() {
+    struct A<X: ?Sized>(X);
+    A as fn(str) -> A<str>;
+    //~^ERROR the size for values of type `str` cannot be known at compilation time
+}
diff --git a/src/test/ui/unsized-locals/issue-50940.stderr b/src/test/ui/unsized-locals/issue-50940.stderr
new file mode 100644
index 00000000000..9f3669ccf1f
--- /dev/null
+++ b/src/test/ui/unsized-locals/issue-50940.stderr
@@ -0,0 +1,14 @@
+error[E0277]: the size for values of type `str` cannot be known at compilation time
+  --> $DIR/issue-50940.rs:3:5
+   |
+LL |     A as fn(str) -> A<str>;
+   |     ^ doesn't have a size known at compile-time
+   |
+   = help: the trait `std::marker::Sized` is not implemented for `str`
+   = note: to learn more, visit <https://doc.rust-lang.org/book/second-edition/ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait>
+   = note: all function arguments must have a statically known size
+   = help: unsized locals are gated as an unstable feature
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0277`.