diff options
Diffstat (limited to 'tests/ui/generics/generic-object.rs')
-rw-r--r-- | tests/ui/generics/generic-object.rs | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/tests/ui/generics/generic-object.rs b/tests/ui/generics/generic-object.rs new file mode 100644 index 000000000..851424a11 --- /dev/null +++ b/tests/ui/generics/generic-object.rs @@ -0,0 +1,21 @@ +// run-pass + +trait Foo<T> { + fn get(&self) -> T; +} + +struct S { + x: isize +} + +impl Foo<isize> for S { + fn get(&self) -> isize { + self.x + } +} + +pub fn main() { + let x = Box::new(S { x: 1 }); + let y = x as Box<dyn Foo<isize>>; + assert_eq!(y.get(), 1); +} |