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