about summary refs log tree commit diff
path: root/src/test/ui/rfc-2027-object-safe-for-dispatch/downcast-unsafe-trait-objects.rs
diff options
context:
space:
mode:
authorMathias Blikstad <mathias@blikstad.se>2019-01-08 22:14:04 +0100
committerNiko Matsakis <niko@alum.mit.edu>2019-10-22 15:24:33 -0400
commitef5acdecebb48a02cb34d19fa17d1bd59e41a4d3 (patch)
treecb6e20d78485549efc93763e17677eefe09ab6fc /src/test/ui/rfc-2027-object-safe-for-dispatch/downcast-unsafe-trait-objects.rs
parentd28a9c38fe14396e86ae274c7847e20ee0f78ca9 (diff)
downloadrust-ef5acdecebb48a02cb34d19fa17d1bd59e41a4d3.tar.gz
rust-ef5acdecebb48a02cb34d19fa17d1bd59e41a4d3.zip
RFC 2027: "first draft" of implementation
These are a squashed series of commits.
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 00000000000..fa04f4b12d5
--- /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() {}