about summary refs log tree commit diff
path: root/tests/ui/delegation/explicit-paths-in-traits-pass.rs
diff options
context:
space:
mode:
authorBryanskiy <ivakin.kir@gmail.com>2023-11-26 15:57:31 +0300
committerBryanskiy <ivakin.kir@gmail.com>2024-01-12 14:11:16 +0300
commitd69cd6473c110096bb009db0f2f21da6f67ac5a6 (patch)
tree9c9ee290363a90b945c89bb88e734af4ac4f0840 /tests/ui/delegation/explicit-paths-in-traits-pass.rs
parent2b1365b34f0d5ee43944c4266a625923a7b312dd (diff)
downloadrust-d69cd6473c110096bb009db0f2f21da6f67ac5a6.tar.gz
rust-d69cd6473c110096bb009db0f2f21da6f67ac5a6.zip
Delegation implementation: step 1
Diffstat (limited to 'tests/ui/delegation/explicit-paths-in-traits-pass.rs')
-rw-r--r--tests/ui/delegation/explicit-paths-in-traits-pass.rs27
1 files changed, 27 insertions, 0 deletions
diff --git a/tests/ui/delegation/explicit-paths-in-traits-pass.rs b/tests/ui/delegation/explicit-paths-in-traits-pass.rs
new file mode 100644
index 00000000000..5c41c2ff49c
--- /dev/null
+++ b/tests/ui/delegation/explicit-paths-in-traits-pass.rs
@@ -0,0 +1,27 @@
+// run-pass
+
+#![feature(fn_delegation)]
+//~^ WARN the feature `fn_delegation` is incomplete
+
+trait ToReuse {
+    fn foo(&self, x: i32) -> i32 { x }
+    fn foo1(x: i32) -> i32 { x }
+}
+
+fn foo2() -> i32 { 42 }
+
+trait Trait: ToReuse {
+    reuse ToReuse::foo;
+    reuse <Self as ToReuse>::foo1;
+    reuse foo2;
+}
+
+struct S;
+impl ToReuse for S {}
+impl Trait for S {}
+
+fn main() {
+    assert_eq!(<S as Trait>::foo(&S, 1), 1);
+    assert_eq!(<S as Trait>::foo1(1), 1);
+    assert_eq!(<S as Trait>::foo2(), 42);
+}