about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/test/ui/dyn-star/check-size-at-cast-polymorphic-bad.rs15
-rw-r--r--src/test/ui/dyn-star/check-size-at-cast-polymorphic-bad.stderr15
-rw-r--r--src/test/ui/dyn-star/check-size-at-cast-polymorphic.rs16
-rw-r--r--src/test/ui/dyn-star/check-size-at-cast.rs10
-rw-r--r--src/test/ui/dyn-star/check-size-at-cast.stderr11
5 files changed, 67 insertions, 0 deletions
diff --git a/src/test/ui/dyn-star/check-size-at-cast-polymorphic-bad.rs b/src/test/ui/dyn-star/check-size-at-cast-polymorphic-bad.rs
new file mode 100644
index 00000000000..e19e36cc7d7
--- /dev/null
+++ b/src/test/ui/dyn-star/check-size-at-cast-polymorphic-bad.rs
@@ -0,0 +1,15 @@
+#![feature(dyn_star)]
+#![allow(incomplete_features)]
+
+use std::fmt::Debug;
+
+fn dyn_debug(_: (dyn* Debug + '_)) {
+
+}
+
+fn polymorphic<T: Debug + ?Sized>(t: &T) {
+    dyn_debug(t);
+    //~^ ERROR `&T` needs to be a pointer-sized type
+}
+
+fn main() {}
diff --git a/src/test/ui/dyn-star/check-size-at-cast-polymorphic-bad.stderr b/src/test/ui/dyn-star/check-size-at-cast-polymorphic-bad.stderr
new file mode 100644
index 00000000000..53ccbe43dcc
--- /dev/null
+++ b/src/test/ui/dyn-star/check-size-at-cast-polymorphic-bad.stderr
@@ -0,0 +1,15 @@
+error[E0277]: `&T` needs to be a pointer-sized type
+  --> $DIR/check-size-at-cast-polymorphic-bad.rs:11:15
+   |
+LL |     dyn_debug(t);
+   |               ^ `&T` needs to be a pointer-sized type
+   |
+   = help: the trait `PointerSized` is not implemented for `&T`
+help: consider introducing a `where` clause, but there might be an alternative better way to express this requirement
+   |
+LL | fn polymorphic<T: Debug + ?Sized>(t: &T) where &T: PointerSized {
+   |                                          ++++++++++++++++++++++
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0277`.
diff --git a/src/test/ui/dyn-star/check-size-at-cast-polymorphic.rs b/src/test/ui/dyn-star/check-size-at-cast-polymorphic.rs
new file mode 100644
index 00000000000..5c0a3d256f6
--- /dev/null
+++ b/src/test/ui/dyn-star/check-size-at-cast-polymorphic.rs
@@ -0,0 +1,16 @@
+// check-pass
+
+#![feature(dyn_star)]
+#![allow(incomplete_features)]
+
+use std::fmt::Debug;
+
+fn dyn_debug(_: (dyn* Debug + '_)) {
+
+}
+
+fn polymorphic<T: Debug>(t: &T) {
+    dyn_debug(t);
+}
+
+fn main() {}
diff --git a/src/test/ui/dyn-star/check-size-at-cast.rs b/src/test/ui/dyn-star/check-size-at-cast.rs
new file mode 100644
index 00000000000..1f22f798361
--- /dev/null
+++ b/src/test/ui/dyn-star/check-size-at-cast.rs
@@ -0,0 +1,10 @@
+#![feature(dyn_star)]
+#![allow(incomplete_features)]
+
+use std::fmt::Debug;
+
+fn main() {
+    let i = [1, 2, 3, 4] as dyn* Debug;
+    //~^ ERROR `[i32; 4]` needs to be a pointer-sized type
+    dbg!(i);
+}
diff --git a/src/test/ui/dyn-star/check-size-at-cast.stderr b/src/test/ui/dyn-star/check-size-at-cast.stderr
new file mode 100644
index 00000000000..af2a1ccf71c
--- /dev/null
+++ b/src/test/ui/dyn-star/check-size-at-cast.stderr
@@ -0,0 +1,11 @@
+error[E0277]: `[i32; 4]` needs to be a pointer-sized type
+  --> $DIR/check-size-at-cast.rs:7:13
+   |
+LL |     let i = [1, 2, 3, 4] as dyn* Debug;
+   |             ^^^^^^^^^^^^ `[i32; 4]` needs to be a pointer-sized type
+   |
+   = help: the trait `PointerSized` is not implemented for `[i32; 4]`
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0277`.