summaryrefslogtreecommitdiffstats
path: root/tests/ui/generics/issue-2936.rs
blob: 6b932d01d55df890ab7c72c267c6437ddb9c1396 (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
// run-pass
#![allow(non_camel_case_types)]

trait bar<T> {
    fn get_bar(&self) -> T;
}

fn foo<T, U: bar<T>>(b: U) -> T {
    b.get_bar()
}

struct cbar {
    x: isize,
}

impl bar<isize> for cbar {
    fn get_bar(&self) -> isize {
        self.x
    }
}

fn cbar(x: isize) -> cbar {
    cbar {
        x: x
    }
}

pub fn main() {
    let x: isize = foo::<isize, cbar>(cbar(5));
    assert_eq!(x, 5);
}