aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/rust/compile/traits8.rs
blob: ccba9fad5dbe3f8575af86aa82a36499dc16a936 (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
#[lang = "sized"]
pub trait Sized {}

trait A {
    fn get(self) -> f64;
}

trait B {
    fn get(self) -> u8;
}

struct Foo(u8, f64);

impl A for Foo {
    fn get(self) -> f64 {
        self.1
    }
}

impl B for Foo {
    fn get(self) -> u8 {
        self.0
    }
}

fn main() {
    let _a;
    _a = Foo(123, 456f64);

    let _b: f64;
    _b = <Foo as A>::get(_a);

    let _a;
    _a = Foo(123, 456f64);

    let _c: u8;
    _c = <Foo as B>::get(_a)
}