]> git.lizzy.rs Git - rust.git/blob - src/test/run-pass/object-method-numbering.rs
Rollup merge of #60685 - dtolnay:spdx, r=nikomatsakis
[rust.git] / src / test / run-pass / object-method-numbering.rs
1 // Test for using an object with an associated type binding as the
2 // instantiation for a generic type with a bound.
3
4
5 trait SomeTrait {
6     type SomeType;
7
8     fn get(&self) -> Self::SomeType;
9 }
10
11 fn get_int<T:SomeTrait<SomeType=i32>+?Sized>(x: &T) -> i32 {
12     x.get()
13 }
14
15 impl SomeTrait for i32 {
16     type SomeType = i32;
17     fn get(&self) -> i32 {
18         *self
19     }
20 }
21
22 fn main() {
23     let x = 22;
24     let x1: &SomeTrait<SomeType=i32> = &x;
25     let y = get_int(x1);
26     assert_eq!(x, y);
27 }