]> git.lizzy.rs Git - rust.git/blob - src/test/ui/associated-types/associated-types-binding-to-type-defined-in-supertrait.rs
Rollup merge of #76468 - SNCPlay42:lifetime-names, r=Mark-Simulacrum
[rust.git] / src / test / ui / associated-types / associated-types-binding-to-type-defined-in-supertrait.rs
1 // Test equality constraints in a where clause where the type being
2 // equated appears in a supertrait.
3
4 pub trait Vehicle {
5     type Color;
6
7     fn go(&self) {  }
8 }
9
10 pub trait Car : Vehicle {
11     fn honk(&self) { }
12 }
13
14 struct Black;
15 struct ModelT;
16 impl Vehicle for ModelT { type Color = Black; }
17 impl Car for ModelT { }
18
19 struct Blue;
20 struct ModelU;
21 impl Vehicle for ModelU { type Color = Blue; }
22 impl Car for ModelU { }
23
24 fn black_car<C:Car<Color=Black>>(c: C) {
25 }
26
27 fn blue_car<C:Car<Color=Blue>>(c: C) {
28 }
29
30 fn a() { black_car(ModelT); }
31 fn b() { blue_car(ModelT); } //~ ERROR type mismatch
32 fn c() { black_car(ModelU); } //~ ERROR type mismatch
33 fn d() { blue_car(ModelU); }
34
35 pub fn main() { }