about summary refs log tree commit diff
path: root/src/test/ui/impl-trait/in-trait
diff options
context:
space:
mode:
authorMichael Goulet <michael@errs.io>2022-09-11 06:58:11 +0000
committerMichael Goulet <michael@errs.io>2022-09-11 06:58:11 +0000
commitfd2766e7fde443d46eb051bb5ef27bbb29ee101d (patch)
tree11c89faf2afce3ba1484620f91561abb891d9d1d /src/test/ui/impl-trait/in-trait
parent98f3001eecbe4cbd091c10ffab45b4c164bb507b (diff)
downloadrust-fd2766e7fde443d46eb051bb5ef27bbb29ee101d.tar.gz
rust-fd2766e7fde443d46eb051bb5ef27bbb29ee101d.zip
Check that the types in RPITITs are WF
Diffstat (limited to 'src/test/ui/impl-trait/in-trait')
-rw-r--r--src/test/ui/impl-trait/in-trait/wf-bounds.rs16
-rw-r--r--src/test/ui/impl-trait/in-trait/wf-bounds.stderr33
2 files changed, 49 insertions, 0 deletions
diff --git a/src/test/ui/impl-trait/in-trait/wf-bounds.rs b/src/test/ui/impl-trait/in-trait/wf-bounds.rs
new file mode 100644
index 00000000000..2c71583b312
--- /dev/null
+++ b/src/test/ui/impl-trait/in-trait/wf-bounds.rs
@@ -0,0 +1,16 @@
+// issue #101663
+
+#![feature(return_position_impl_trait_in_trait)]
+#![allow(incomplete_features)]
+
+trait Wf<T> {}
+
+trait Uwu {
+    fn nya() -> impl Wf<Vec<[u8]>>;
+    //~^ ERROR the size for values of type `[u8]` cannot be known at compilation time
+
+    fn nya2() -> impl Wf<[u8]>;
+    //~^ ERROR the size for values of type `[u8]` cannot be known at compilation time
+}
+
+fn main() {}
diff --git a/src/test/ui/impl-trait/in-trait/wf-bounds.stderr b/src/test/ui/impl-trait/in-trait/wf-bounds.stderr
new file mode 100644
index 00000000000..92e36841b70
--- /dev/null
+++ b/src/test/ui/impl-trait/in-trait/wf-bounds.stderr
@@ -0,0 +1,33 @@
+error[E0277]: the size for values of type `[u8]` cannot be known at compilation time
+  --> $DIR/wf-bounds.rs:9:22
+   |
+LL |     fn nya() -> impl Wf<Vec<[u8]>>;
+   |                      ^^^^^^^^^^^^^ doesn't have a size known at compile-time
+   |
+   = help: the trait `Sized` is not implemented for `[u8]`
+note: required by a bound in `Vec`
+  --> $SRC_DIR/alloc/src/vec/mod.rs:LL:COL
+   |
+LL | pub struct Vec<T, #[unstable(feature = "allocator_api", issue = "32838")] A: Allocator = Global> {
+   |                ^ required by this bound in `Vec`
+
+error[E0277]: the size for values of type `[u8]` cannot be known at compilation time
+  --> $DIR/wf-bounds.rs:12:23
+   |
+LL |     fn nya2() -> impl Wf<[u8]>;
+   |                       ^^^^^^^^ doesn't have a size known at compile-time
+   |
+   = help: the trait `Sized` is not implemented for `[u8]`
+note: required by a bound in `Wf`
+  --> $DIR/wf-bounds.rs:6:10
+   |
+LL | trait Wf<T> {}
+   |          ^ required by this bound in `Wf`
+help: consider relaxing the implicit `Sized` restriction
+   |
+LL | trait Wf<T: ?Sized> {}
+   |           ++++++++
+
+error: aborting due to 2 previous errors
+
+For more information about this error, try `rustc --explain E0277`.