From 698f8c2f01ea549d77d7dc3338a12e04c11057b9 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 17 Apr 2024 14:02:58 +0200 Subject: Adding upstream version 1.64.0+dfsg1. Signed-off-by: Daniel Baumann --- .../associated-type-projection-from-supertrait.rs | 36 ++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 src/test/ui/associated-types/associated-type-projection-from-supertrait.rs (limited to 'src/test/ui/associated-types/associated-type-projection-from-supertrait.rs') diff --git a/src/test/ui/associated-types/associated-type-projection-from-supertrait.rs b/src/test/ui/associated-types/associated-type-projection-from-supertrait.rs new file mode 100644 index 000000000..7e05bcd30 --- /dev/null +++ b/src/test/ui/associated-types/associated-type-projection-from-supertrait.rs @@ -0,0 +1,36 @@ +// Test equality constraints in a where clause where the type being +// equated appears in a supertrait. + +pub trait Vehicle { + type Color; + + fn go(&self) { } +} + +pub trait Car : Vehicle { + fn honk(&self) { } + fn chip_paint(&self, c: Self::Color) { } +} + +struct Black; +struct ModelT; +impl Vehicle for ModelT { type Color = Black; } +impl Car for ModelT { } + +struct Blue; +struct ModelU; +impl Vehicle for ModelU { type Color = Blue; } +impl Car for ModelU { } + +fn dent(c: C, color: C::Color) { c.chip_paint(color) } +fn a() { dent(ModelT, Black); } +fn b() { dent(ModelT, Blue); } //~ ERROR mismatched types +fn c() { dent(ModelU, Black); } //~ ERROR mismatched types +fn d() { dent(ModelU, Blue); } + +fn e() { ModelT.chip_paint(Black); } +fn f() { ModelT.chip_paint(Blue); } //~ ERROR mismatched types +fn g() { ModelU.chip_paint(Black); } //~ ERROR mismatched types +fn h() { ModelU.chip_paint(Blue); } + +pub fn main() { } -- cgit v1.2.3