about summary refs log tree commit diff
path: root/tests/ui/delegation/glob-override.rs
blob: 1d0dcf1df6e606609dadf5c1cd4cfe3e75ff2a2b (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
//@ 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 }
    fn bar(&self) -> u8 { 2 }
}

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

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

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