From 698f8c2f01ea549d77d7dc3338a12e04c11057b9 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 17 Apr 2024 14:02:58 +0200 Subject: Adding upstream version 1.64.0+dfsg1. Signed-off-by: Daniel Baumann --- src/test/ui/traits/inheritance/cross-trait-call.rs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 src/test/ui/traits/inheritance/cross-trait-call.rs (limited to 'src/test/ui/traits/inheritance/cross-trait-call.rs') diff --git a/src/test/ui/traits/inheritance/cross-trait-call.rs b/src/test/ui/traits/inheritance/cross-trait-call.rs new file mode 100644 index 000000000..512c928ca --- /dev/null +++ b/src/test/ui/traits/inheritance/cross-trait-call.rs @@ -0,0 +1,19 @@ +// run-pass +#![allow(dead_code)] + +trait Foo { fn f(&self) -> isize; } +trait Bar : Foo { fn g(&self) -> isize; } + +struct A { x: isize } + +impl Foo for A { fn f(&self) -> isize { 10 } } + +impl Bar for A { + // Testing that this impl can call the impl of Foo + fn g(&self) -> isize { self.f() } +} + +pub fn main() { + let a = &A { x: 3 }; + assert_eq!(a.g(), 10); +} -- cgit v1.2.3