]> git.lizzy.rs Git - rust.git/blob - tests/ui/associated-types/associated-type-projection-from-supertrait.rs
Rollup merge of #107306 - compiler-errors:correct-sugg-for-closure-arg-needs-borrow...
[rust.git] / tests / ui / associated-types / associated-type-projection-from-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     fn chip_paint(&self, c: Self::Color) { }
13 }
14
15 struct Black;
16 struct ModelT;
17 impl Vehicle for ModelT { type Color = Black; }
18 impl Car for ModelT { }
19
20 struct Blue;
21 struct ModelU;
22 impl Vehicle for ModelU { type Color = Blue; }
23 impl Car for ModelU { }
24
25 fn dent<C:Car>(c: C, color: C::Color) { c.chip_paint(color) }
26 fn a() { dent(ModelT, Black); }
27 fn b() { dent(ModelT, Blue); } //~ ERROR mismatched types
28 fn c() { dent(ModelU, Black); } //~ ERROR mismatched types
29 fn d() { dent(ModelU, Blue); }
30
31 fn e() { ModelT.chip_paint(Black); }
32 fn f() { ModelT.chip_paint(Blue); } //~ ERROR mismatched types
33 fn g() { ModelU.chip_paint(Black); } //~ ERROR mismatched types
34 fn h() { ModelU.chip_paint(Blue); }
35
36 pub fn main() { }