rust/tests/ui/delegation/list.rs
Vadim Petrochenkov c30b41012d delegation: Implement list delegation
```rust
reuse prefix::{a, b, c}
```
2024-05-15 02:32:59 +03:00

47 lines
601 B
Rust

//@ check-pass
#![feature(fn_delegation)]
#![allow(incomplete_features)]
trait Trait {
fn foo(&self) -> u8 { 0 }
fn bar(&self) -> u8 { 1 }
}
impl Trait for u8 {}
struct S(u8);
struct Z(u8);
impl Trait for S {
reuse Trait::{foo, bar} { &self.0 }
}
impl Trait for Z {
reuse <u8 as Trait>::{foo, bar} { &self.0 }
}
trait Trait2 where Self: Trait {
reuse Trait::{foo, bar};
}
mod to_reuse {
pub fn a() {}
pub fn b() {}
}
reuse to_reuse::{a, b};
fn main() {
let s = S(2);
s.foo();
s.bar();
let z = Z(3);
z.foo();
z.bar();
a();
b();
}