diff options
Diffstat (limited to 'tests/ui/traits/region-pointer-simple.rs')
-rw-r--r-- | tests/ui/traits/region-pointer-simple.rs | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/tests/ui/traits/region-pointer-simple.rs b/tests/ui/traits/region-pointer-simple.rs new file mode 100644 index 000000000..0456ca931 --- /dev/null +++ b/tests/ui/traits/region-pointer-simple.rs @@ -0,0 +1,21 @@ +// run-pass +trait Foo { + fn f(&self) -> isize; +} + +struct A { + x: isize +} + +impl Foo for A { + fn f(&self) -> isize { + println!("Today's number is {}", self.x); + return self.x; + } +} + +pub fn main() { + let a = A { x: 3 }; + let b = (&a) as &dyn Foo; + assert_eq!(b.f(), 3); +} |