summaryrefslogtreecommitdiffstats
path: root/src/test/ui/rfc-2027-object-safe-for-dispatch/downcast-unsafe-trait-objects.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/ui/rfc-2027-object-safe-for-dispatch/downcast-unsafe-trait-objects.rs')
-rw-r--r--src/test/ui/rfc-2027-object-safe-for-dispatch/downcast-unsafe-trait-objects.rs23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/test/ui/rfc-2027-object-safe-for-dispatch/downcast-unsafe-trait-objects.rs b/src/test/ui/rfc-2027-object-safe-for-dispatch/downcast-unsafe-trait-objects.rs
new file mode 100644
index 000000000..fa04f4b12
--- /dev/null
+++ b/src/test/ui/rfc-2027-object-safe-for-dispatch/downcast-unsafe-trait-objects.rs
@@ -0,0 +1,23 @@
+// Check that we if we get ahold of an object unsafe trait
+// object with auto traits and lifetimes, we can downcast it
+//
+// check-pass
+
+#![feature(object_safe_for_dispatch)]
+
+trait Trait: Sized {}
+
+fn downcast_auto(t: &(dyn Trait + Send)) -> &dyn Trait {
+ t
+}
+
+fn downcast_lifetime<'a, 'b, 't>(t: &'a (dyn Trait + 't))
+ -> &'b (dyn Trait + 't)
+where
+ 'a: 'b,
+ 't: 'a + 'b,
+{
+ t
+}
+
+fn main() {}