summaryrefslogtreecommitdiffstats
path: root/tests/ui/impl-trait/in-trait/object-safety.rs
diff options
context:
space:
mode:
Diffstat (limited to 'tests/ui/impl-trait/in-trait/object-safety.rs')
-rw-r--r--tests/ui/impl-trait/in-trait/object-safety.rs22
1 files changed, 22 insertions, 0 deletions
diff --git a/tests/ui/impl-trait/in-trait/object-safety.rs b/tests/ui/impl-trait/in-trait/object-safety.rs
new file mode 100644
index 000000000..dd35b9a2d
--- /dev/null
+++ b/tests/ui/impl-trait/in-trait/object-safety.rs
@@ -0,0 +1,22 @@
+#![feature(return_position_impl_trait_in_trait)]
+#![allow(incomplete_features)]
+
+use std::fmt::Debug;
+
+trait Foo {
+ fn baz(&self) -> impl Debug;
+}
+
+impl Foo for u32 {
+ fn baz(&self) -> u32 {
+ 32
+ }
+}
+
+fn main() {
+ let i = Box::new(42_u32) as Box<dyn Foo>;
+ //~^ ERROR the trait `Foo` cannot be made into an object
+ //~| ERROR the trait `Foo` cannot be made into an object
+ let s = i.baz();
+ //~^ ERROR the trait `Foo` cannot be made into an object
+}