]> git.proxmox.com Git - rustc.git/blame - src/test/ui/run-pass/issues/issue-2936.rs
New upstream version 1.30.0+dfsg1
[rustc.git] / src / test / ui / run-pass / issues / issue-2936.rs
CommitLineData
223e47cc
LB
1// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
2// file at the top-level directory of this distribution and at
3// http://rust-lang.org/COPYRIGHT.
4//
5// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8// option. This file may not be copied, modified, or distributed
9// except according to those terms.
10
b7449926
XL
11// run-pass
12#![allow(non_camel_case_types)]
c34b1796 13
223e47cc
LB
14trait bar<T> {
15 fn get_bar(&self) -> T;
16}
17
18fn foo<T, U: bar<T>>(b: U) -> T {
19 b.get_bar()
20}
21
22struct cbar {
c34b1796 23 x: isize,
223e47cc
LB
24}
25
c34b1796
AL
26impl bar<isize> for cbar {
27 fn get_bar(&self) -> isize {
223e47cc
LB
28 self.x
29 }
30}
31
c34b1796 32fn cbar(x: isize) -> cbar {
223e47cc
LB
33 cbar {
34 x: x
35 }
36}
37
38pub fn main() {
c34b1796 39 let x: isize = foo::<isize, cbar>(cbar(5));
970d7e83 40 assert_eq!(x, 5);
223e47cc 41}