aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/rust/execute/torture/impl_trait4.rs
blob: 67d00957e3d65d5970ad576cc6781c52bc805039 (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
#[lang = "sized"]
trait Sized {}

trait Foo {
    fn id(&self) -> i32;
}

struct A(i32);
struct B(i32);

impl Foo for A {
    fn id(&self) -> i32 {
        self.0
    }
}

impl Foo for B {
    fn id(&self) -> i32 {
        self.0
    }
}

fn takes_tuple(pair: (impl Foo, impl Foo)) -> i32 {
    pair.0.id() + pair.1.id()
}

fn main() -> i32 {
    let a = A(1);
    let b = B(2);
    takes_tuple((a, b)) - 3
}