about summary refs log tree commit diff
path: root/tests/ui/delegation/glob.rs
blob: 5bc80c166489702fa8091a7b5a4dc9c47cc551b2 (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
//@ check-pass

#![feature(fn_delegation)]
#![allow(incomplete_features)]

trait Trait {
    fn foo(&self) -> u8;
    fn bar(&self) -> u8;
}

impl Trait for u8 {
    fn foo(&self) -> u8 { 0 }
    fn bar(&self) -> u8 { 1 }
}

struct S(u8);
struct Z(u8);

impl Trait for S {
    reuse Trait::* { &self.0 }
}

impl Trait for Z {
    reuse <u8 as Trait>::* { &self.0 }
}

fn main() {
    let s = S(2);
    s.foo();
    s.bar();

    let z = Z(3);
    z.foo();
    z.bar();
}