summary refs log tree commit diff
path: root/src/test/compile-fail/vtable-res-trait-param.rs
blob: 8032c199bf099f619ad0dc4193a6c40271c15477 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
trait TraitA {
    fn method_a() -> int;
}

trait TraitB {
    fn gimme_an_a<A: TraitA>(a: A) -> int;
}

impl int: TraitB {
    fn gimme_an_a<A: TraitA>(a: A) -> int {
        a.method_a() + self
    }
}

fn call_it<B: TraitB>(b: B)  -> int {
    let y = 4u;
    b.gimme_an_a(y) //~ ERROR failed to find an implementation of trait @TraitA
}

fn main() {
    let x = 3i;
    assert call_it(x) == 22;
}