about summary refs log tree commit diff
path: root/tests/ui/delegation/list.rs
blob: 208b14816797ad38aba4f37737c624f55b4152b8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
//@ 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();
}