]> git.lizzy.rs Git - rust.git/blob - src/test/ui/traits/object-one-type-two-traits.rs
Auto merge of #87284 - Aaron1011:remove-paren-special, r=petrochenkov
[rust.git] / src / test / ui / traits / object-one-type-two-traits.rs
1 // run-pass
2 #![allow(dead_code)]
3 #![allow(unused_variables)]
4 // Testing creating two vtables with the same self type, but different
5 // traits.
6
7 #![feature(box_syntax)]
8
9 use std::any::Any;
10
11 trait Wrap {
12     fn get(&self) -> isize;
13     fn wrap(self: Box<Self>) -> Box<dyn Any+'static>;
14 }
15
16 impl Wrap for isize {
17     fn get(&self) -> isize {
18         *self
19     }
20     fn wrap(self: Box<isize>) -> Box<dyn Any+'static> {
21         self as Box<dyn Any+'static>
22     }
23 }
24
25 fn is<T:Any>(x: &dyn Any) -> bool {
26     x.is::<T>()
27 }
28
29 fn main() {
30     let x = box 22isize as Box<dyn Wrap>;
31     println!("x={}", x.get());
32     let y = x.wrap();
33 }