]> git.proxmox.com Git - rustc.git/blobdiff - src/test/ui/traits/kindck-owned-contains-1.rs
Merge tag 'debian/1.52.1+dfsg1-1_exp2' into proxmox/buster
[rustc.git] / src / test / ui / traits / kindck-owned-contains-1.rs
diff --git a/src/test/ui/traits/kindck-owned-contains-1.rs b/src/test/ui/traits/kindck-owned-contains-1.rs
new file mode 100644 (file)
index 0000000..23b91f9
--- /dev/null
@@ -0,0 +1,23 @@
+// run-pass
+#![allow(non_snake_case)]
+#![allow(non_camel_case_types)]
+
+#![feature(box_syntax)]
+
+trait repeat<A> { fn get(&self) -> A; }
+
+impl<A:Clone + 'static> repeat<A> for Box<A> {
+    fn get(&self) -> A {
+        (**self).clone()
+    }
+}
+
+fn repeater<A:Clone + 'static>(v: Box<A>) -> Box<dyn repeat<A>+'static> {
+    box v as Box<dyn repeat<A>+'static> // No
+}
+
+pub fn main() {
+    let x = 3;
+    let y = repeater(box x);
+    assert_eq!(x, y.get());
+}