From 218caa410aa38c29984be31a5229b9fa717560ee Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 17 Apr 2024 14:19:13 +0200 Subject: Merging upstream version 1.68.2+dfsg1. Signed-off-by: Daniel Baumann --- .../associated-types-in-inherent-method.rs | 30 ++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 tests/ui/associated-types/associated-types-in-inherent-method.rs (limited to 'tests/ui/associated-types/associated-types-in-inherent-method.rs') diff --git a/tests/ui/associated-types/associated-types-in-inherent-method.rs b/tests/ui/associated-types/associated-types-in-inherent-method.rs new file mode 100644 index 000000000..1f29e9668 --- /dev/null +++ b/tests/ui/associated-types/associated-types-in-inherent-method.rs @@ -0,0 +1,30 @@ +// run-pass + +trait Get { + type Value; + fn get(&self) -> &::Value; +} + +struct Struct { + x: isize, +} + +impl Get for Struct { + type Value = isize; + fn get(&self) -> &isize { + &self.x + } +} + +impl Struct { + fn grab(x: &T) -> &::Value { + x.get() + } +} + +fn main() { + let s = Struct { + x: 100, + }; + assert_eq!(*Struct::grab(&s), 100); +} -- cgit v1.2.3