diff options
| author | Bryanskiy <ivakin.kir@gmail.com> | 2023-11-26 15:57:31 +0300 |
|---|---|---|
| committer | Bryanskiy <ivakin.kir@gmail.com> | 2024-01-12 14:11:16 +0300 |
| commit | d69cd6473c110096bb009db0f2f21da6f67ac5a6 (patch) | |
| tree | 9c9ee290363a90b945c89bb88e734af4ac4f0840 /tests/ui/delegation/explicit-paths-in-traits-pass.rs | |
| parent | 2b1365b34f0d5ee43944c4266a625923a7b312dd (diff) | |
| download | rust-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.rs | 27 |
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); +} |
