]> git.lizzy.rs Git - rust.git/blob - src/test/ui/associated-types/associated-types-binding-in-where-clause.rs
Rollup merge of #76468 - SNCPlay42:lifetime-names, r=Mark-Simulacrum
[rust.git] / src / test / ui / associated-types / associated-types-binding-in-where-clause.rs
1 // run-pass
2 // Test equality constraints on associated types in a where clause.
3
4 // pretty-expanded FIXME #23616
5
6 pub trait Foo {
7     type A;
8     fn boo(&self) -> <Self as Foo>::A;
9 }
10
11 #[derive(PartialEq)]
12 pub struct Bar;
13
14 impl Foo for isize {
15     type A = usize;
16     fn boo(&self) -> usize { 42 }
17 }
18
19 impl Foo for char {
20     type A = Bar;
21     fn boo(&self) -> Bar { Bar }
22 }
23
24 fn foo_bar<I: Foo<A=Bar>>(x: I) -> Bar {
25     x.boo()
26 }
27
28 fn foo_uint<I: Foo<A=usize>>(x: I) -> usize {
29     x.boo()
30 }
31
32 pub fn main() {
33     let a = 42;
34     foo_uint(a);
35
36     let a = 'a';
37     foo_bar(a);
38 }