]> git.lizzy.rs Git - rust.git/blob - tests/ui/generics/issue-2936.rs
Rollup merge of #106144 - tgross35:patch-1, r=Mark-Simulacrum
[rust.git] / tests / ui / generics / issue-2936.rs
1 // run-pass
2 #![allow(non_camel_case_types)]
3
4 trait bar<T> {
5     fn get_bar(&self) -> T;
6 }
7
8 fn foo<T, U: bar<T>>(b: U) -> T {
9     b.get_bar()
10 }
11
12 struct cbar {
13     x: isize,
14 }
15
16 impl bar<isize> for cbar {
17     fn get_bar(&self) -> isize {
18         self.x
19     }
20 }
21
22 fn cbar(x: isize) -> cbar {
23     cbar {
24         x: x
25     }
26 }
27
28 pub fn main() {
29     let x: isize = foo::<isize, cbar>(cbar(5));
30     assert_eq!(x, 5);
31 }