]> git.lizzy.rs Git - rust.git/commitdiff
Migrate from `associated-type` to `associated-types`
authorYuki Okushi <huyuumi.dev@gmail.com>
Thu, 15 Oct 2020 01:25:23 +0000 (10:25 +0900)
committerYuki Okushi <huyuumi.dev@gmail.com>
Thu, 15 Oct 2020 01:25:23 +0000 (10:25 +0900)
12 files changed:
src/test/ui/associated-type/associated-type-projection-ambig-between-bound-and-where-clause.rs [deleted file]
src/test/ui/associated-type/associated-type-projection-ambig-between-bound-and-where-clause.stderr [deleted file]
src/test/ui/associated-type/associated-type-projection-from-multiple-supertraits.rs [deleted file]
src/test/ui/associated-type/associated-type-projection-from-multiple-supertraits.stderr [deleted file]
src/test/ui/associated-type/associated-type-projection-from-supertrait.rs [deleted file]
src/test/ui/associated-type/associated-type-projection-from-supertrait.stderr [deleted file]
src/test/ui/associated-types/associated-type-projection-ambig-between-bound-and-where-clause.rs [new file with mode: 0644]
src/test/ui/associated-types/associated-type-projection-ambig-between-bound-and-where-clause.stderr [new file with mode: 0644]
src/test/ui/associated-types/associated-type-projection-from-multiple-supertraits.rs [new file with mode: 0644]
src/test/ui/associated-types/associated-type-projection-from-multiple-supertraits.stderr [new file with mode: 0644]
src/test/ui/associated-types/associated-type-projection-from-supertrait.rs [new file with mode: 0644]
src/test/ui/associated-types/associated-type-projection-from-supertrait.stderr [new file with mode: 0644]

diff --git a/src/test/ui/associated-type/associated-type-projection-ambig-between-bound-and-where-clause.rs b/src/test/ui/associated-type/associated-type-projection-ambig-between-bound-and-where-clause.rs
deleted file mode 100644 (file)
index c85d41c..0000000
+++ /dev/null
@@ -1,42 +0,0 @@
-// 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 Box {
-    type Color;
-
-    fn mail(&self) {  }
-}
-
-fn a<C:Vehicle+Box>(_: C::Color) {
-    //~^ ERROR ambiguous associated type `Color` in bounds of `C`
-}
-
-fn b<C>(_: C::Color) where C : Vehicle+Box {
-    //~^ ERROR ambiguous associated type `Color` in bounds of `C`
-}
-
-fn c<C>(_: C::Color) where C : Vehicle, C : Box {
-    //~^ ERROR ambiguous associated type `Color` in bounds of `C`
-}
-
-struct D<X>;
-impl<X> D<X> where X : Vehicle {
-    fn d(&self, _: X::Color) where X : Box { }
-    //~^ ERROR ambiguous associated type `Color` in bounds of `X`
-}
-
-trait E<X:Vehicle> {
-    fn e(&self, _: X::Color) where X : Box;
-    //~^ ERROR ambiguous associated type `Color` in bounds of `X`
-
-    fn f(&self, _: X::Color) where X : Box { }
-    //~^ ERROR ambiguous associated type `Color` in bounds of `X`
-}
-
-pub fn main() { }
diff --git a/src/test/ui/associated-type/associated-type-projection-ambig-between-bound-and-where-clause.stderr b/src/test/ui/associated-type/associated-type-projection-ambig-between-bound-and-where-clause.stderr
deleted file mode 100644 (file)
index 6de8459..0000000
+++ /dev/null
@@ -1,129 +0,0 @@
-error[E0221]: ambiguous associated type `Color` in bounds of `C`
-  --> $DIR/associated-type-projection-ambig-between-bound-and-where-clause.rs:16:24
-   |
-LL |     type Color;
-   |     ----------- ambiguous `Color` from `Vehicle`
-...
-LL |     type Color;
-   |     ----------- ambiguous `Color` from `Box`
-...
-LL | fn a<C:Vehicle+Box>(_: C::Color) {
-   |                        ^^^^^^^^ ambiguous associated type `Color`
-   |
-help: use fully qualified syntax to disambiguate
-   |
-LL | fn a<C:Vehicle+Box>(_: <C as Box>::Color) {
-   |                        ^^^^^^^^^^^^^^^^^
-help: use fully qualified syntax to disambiguate
-   |
-LL | fn a<C:Vehicle+Box>(_: <C as Vehicle>::Color) {
-   |                        ^^^^^^^^^^^^^^^^^^^^^
-
-error[E0221]: ambiguous associated type `Color` in bounds of `C`
-  --> $DIR/associated-type-projection-ambig-between-bound-and-where-clause.rs:20:12
-   |
-LL |     type Color;
-   |     ----------- ambiguous `Color` from `Vehicle`
-...
-LL |     type Color;
-   |     ----------- ambiguous `Color` from `Box`
-...
-LL | fn b<C>(_: C::Color) where C : Vehicle+Box {
-   |            ^^^^^^^^ ambiguous associated type `Color`
-   |
-help: use fully qualified syntax to disambiguate
-   |
-LL | fn b<C>(_: <C as Box>::Color) where C : Vehicle+Box {
-   |            ^^^^^^^^^^^^^^^^^
-help: use fully qualified syntax to disambiguate
-   |
-LL | fn b<C>(_: <C as Vehicle>::Color) where C : Vehicle+Box {
-   |            ^^^^^^^^^^^^^^^^^^^^^
-
-error[E0221]: ambiguous associated type `Color` in bounds of `C`
-  --> $DIR/associated-type-projection-ambig-between-bound-and-where-clause.rs:24:12
-   |
-LL |     type Color;
-   |     ----------- ambiguous `Color` from `Vehicle`
-...
-LL |     type Color;
-   |     ----------- ambiguous `Color` from `Box`
-...
-LL | fn c<C>(_: C::Color) where C : Vehicle, C : Box {
-   |            ^^^^^^^^ ambiguous associated type `Color`
-   |
-help: use fully qualified syntax to disambiguate
-   |
-LL | fn c<C>(_: <C as Box>::Color) where C : Vehicle, C : Box {
-   |            ^^^^^^^^^^^^^^^^^
-help: use fully qualified syntax to disambiguate
-   |
-LL | fn c<C>(_: <C as Vehicle>::Color) where C : Vehicle, C : Box {
-   |            ^^^^^^^^^^^^^^^^^^^^^
-
-error[E0221]: ambiguous associated type `Color` in bounds of `X`
-  --> $DIR/associated-type-projection-ambig-between-bound-and-where-clause.rs:35:20
-   |
-LL |     type Color;
-   |     ----------- ambiguous `Color` from `Vehicle`
-...
-LL |     type Color;
-   |     ----------- ambiguous `Color` from `Box`
-...
-LL |     fn e(&self, _: X::Color) where X : Box;
-   |                    ^^^^^^^^ ambiguous associated type `Color`
-   |
-help: use fully qualified syntax to disambiguate
-   |
-LL |     fn e(&self, _: <X as Box>::Color) where X : Box;
-   |                    ^^^^^^^^^^^^^^^^^
-help: use fully qualified syntax to disambiguate
-   |
-LL |     fn e(&self, _: <X as Vehicle>::Color) where X : Box;
-   |                    ^^^^^^^^^^^^^^^^^^^^^
-
-error[E0221]: ambiguous associated type `Color` in bounds of `X`
-  --> $DIR/associated-type-projection-ambig-between-bound-and-where-clause.rs:38:20
-   |
-LL |     type Color;
-   |     ----------- ambiguous `Color` from `Vehicle`
-...
-LL |     type Color;
-   |     ----------- ambiguous `Color` from `Box`
-...
-LL |     fn f(&self, _: X::Color) where X : Box { }
-   |                    ^^^^^^^^ ambiguous associated type `Color`
-   |
-help: use fully qualified syntax to disambiguate
-   |
-LL |     fn f(&self, _: <X as Box>::Color) where X : Box { }
-   |                    ^^^^^^^^^^^^^^^^^
-help: use fully qualified syntax to disambiguate
-   |
-LL |     fn f(&self, _: <X as Vehicle>::Color) where X : Box { }
-   |                    ^^^^^^^^^^^^^^^^^^^^^
-
-error[E0221]: ambiguous associated type `Color` in bounds of `X`
-  --> $DIR/associated-type-projection-ambig-between-bound-and-where-clause.rs:30:20
-   |
-LL |     type Color;
-   |     ----------- ambiguous `Color` from `Vehicle`
-...
-LL |     type Color;
-   |     ----------- ambiguous `Color` from `Box`
-...
-LL |     fn d(&self, _: X::Color) where X : Box { }
-   |                    ^^^^^^^^ ambiguous associated type `Color`
-   |
-help: use fully qualified syntax to disambiguate
-   |
-LL |     fn d(&self, _: <X as Box>::Color) where X : Box { }
-   |                    ^^^^^^^^^^^^^^^^^
-help: use fully qualified syntax to disambiguate
-   |
-LL |     fn d(&self, _: <X as Vehicle>::Color) where X : Box { }
-   |                    ^^^^^^^^^^^^^^^^^^^^^
-
-error: aborting due to 6 previous errors
-
-For more information about this error, try `rustc --explain E0221`.
diff --git a/src/test/ui/associated-type/associated-type-projection-from-multiple-supertraits.rs b/src/test/ui/associated-type/associated-type-projection-from-multiple-supertraits.rs
deleted file mode 100644 (file)
index df19332..0000000
+++ /dev/null
@@ -1,43 +0,0 @@
-// 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 Box {
-    type Color;
-    //
-    fn mail(&self) {  }
-}
-
-pub trait BoxCar : Box + Vehicle {
-}
-
-fn dent<C:BoxCar>(c: C, color: C::Color) {
-    //~^ ERROR ambiguous associated type `Color` in bounds of `C`
-}
-
-fn dent_object<COLOR>(c: dyn BoxCar<Color=COLOR>) {
-    //~^ ERROR ambiguous associated type
-    //~| ERROR the value of the associated types
-}
-
-fn paint<C:BoxCar>(c: C, d: C::Color) {
-    //~^ ERROR ambiguous associated type `Color` in bounds of `C`
-}
-
-fn dent_object_2<COLOR>(c: dyn BoxCar) where <dyn BoxCar as Vehicle>::Color = COLOR {
-    //~^ ERROR the value of the associated types
-    //~| ERROR equality constraints are not yet supported in `where` clauses
-}
-
-fn dent_object_3<X, COLOR>(c: X)
-where X: BoxCar,
-    X: Vehicle<Color = COLOR>,
-    X: Box<Color = COLOR>
-{} // OK!
-
-pub fn main() { }
diff --git a/src/test/ui/associated-type/associated-type-projection-from-multiple-supertraits.stderr b/src/test/ui/associated-type/associated-type-projection-from-multiple-supertraits.stderr
deleted file mode 100644 (file)
index b6a8817..0000000
+++ /dev/null
@@ -1,100 +0,0 @@
-error: equality constraints are not yet supported in `where` clauses
-  --> $DIR/associated-type-projection-from-multiple-supertraits.rs:32:46
-   |
-LL | fn dent_object_2<COLOR>(c: dyn BoxCar) where <dyn BoxCar as Vehicle>::Color = COLOR {
-   |                                              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not supported
-   |
-   = note: see issue #20041 <https://github.com/rust-lang/rust/issues/20041> for more information
-
-error[E0221]: ambiguous associated type `Color` in bounds of `C`
-  --> $DIR/associated-type-projection-from-multiple-supertraits.rs:19:32
-   |
-LL |     type Color;
-   |     ----------- ambiguous `Color` from `Vehicle`
-...
-LL |     type Color;
-   |     ----------- ambiguous `Color` from `Box`
-...
-LL | fn dent<C:BoxCar>(c: C, color: C::Color) {
-   |                                ^^^^^^^^ ambiguous associated type `Color`
-   |
-help: use fully qualified syntax to disambiguate
-   |
-LL | fn dent<C:BoxCar>(c: C, color: <C as Box>::Color) {
-   |                                ^^^^^^^^^^^^^^^^^
-help: use fully qualified syntax to disambiguate
-   |
-LL | fn dent<C:BoxCar>(c: C, color: <C as Vehicle>::Color) {
-   |                                ^^^^^^^^^^^^^^^^^^^^^
-
-error[E0222]: ambiguous associated type `Color` in bounds of `BoxCar`
-  --> $DIR/associated-type-projection-from-multiple-supertraits.rs:23:37
-   |
-LL |     type Color;
-   |     ----------- ambiguous `Color` from `Vehicle`
-...
-LL |     type Color;
-   |     ----------- ambiguous `Color` from `Box`
-...
-LL | fn dent_object<COLOR>(c: dyn BoxCar<Color=COLOR>) {
-   |                                     ^^^^^^^^^^^ ambiguous associated type `Color`
-   |
-   = help: consider introducing a new type parameter `T` and adding `where` constraints:
-               where
-                   T: BoxCar,
-                   T: Box::Color = COLOR,
-                   T: Vehicle::Color = COLOR
-
-error[E0191]: the value of the associated types `Color` (from trait `Box`), `Color` (from trait `Vehicle`) must be specified
-  --> $DIR/associated-type-projection-from-multiple-supertraits.rs:23:30
-   |
-LL |     type Color;
-   |     ----------- `Vehicle::Color` defined here
-...
-LL |     type Color;
-   |     ----------- `Box::Color` defined here
-...
-LL | fn dent_object<COLOR>(c: dyn BoxCar<Color=COLOR>) {
-   |                              ^^^^^^^^^^^^^^^^^^^ associated types `Color` (from trait `Vehicle`), `Color` (from trait `Box`) must be specified
-   |
-   = help: consider introducing a new type parameter, adding `where` constraints using the fully-qualified path to the associated types
-
-error[E0221]: ambiguous associated type `Color` in bounds of `C`
-  --> $DIR/associated-type-projection-from-multiple-supertraits.rs:28:29
-   |
-LL |     type Color;
-   |     ----------- ambiguous `Color` from `Vehicle`
-...
-LL |     type Color;
-   |     ----------- ambiguous `Color` from `Box`
-...
-LL | fn paint<C:BoxCar>(c: C, d: C::Color) {
-   |                             ^^^^^^^^ ambiguous associated type `Color`
-   |
-help: use fully qualified syntax to disambiguate
-   |
-LL | fn paint<C:BoxCar>(c: C, d: <C as Box>::Color) {
-   |                             ^^^^^^^^^^^^^^^^^
-help: use fully qualified syntax to disambiguate
-   |
-LL | fn paint<C:BoxCar>(c: C, d: <C as Vehicle>::Color) {
-   |                             ^^^^^^^^^^^^^^^^^^^^^
-
-error[E0191]: the value of the associated types `Color` (from trait `Box`), `Color` (from trait `Vehicle`) must be specified
-  --> $DIR/associated-type-projection-from-multiple-supertraits.rs:32:32
-   |
-LL |     type Color;
-   |     ----------- `Vehicle::Color` defined here
-...
-LL |     type Color;
-   |     ----------- `Box::Color` defined here
-...
-LL | fn dent_object_2<COLOR>(c: dyn BoxCar) where <dyn BoxCar as Vehicle>::Color = COLOR {
-   |                                ^^^^^^ associated types `Color` (from trait `Vehicle`), `Color` (from trait `Box`) must be specified
-   |
-   = help: consider introducing a new type parameter, adding `where` constraints using the fully-qualified path to the associated types
-
-error: aborting due to 6 previous errors
-
-Some errors have detailed explanations: E0191, E0221, E0222.
-For more information about an error, try `rustc --explain E0191`.
diff --git a/src/test/ui/associated-type/associated-type-projection-from-supertrait.rs b/src/test/ui/associated-type/associated-type-projection-from-supertrait.rs
deleted file mode 100644 (file)
index 7e05bcd..0000000
+++ /dev/null
@@ -1,36 +0,0 @@
-// 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:Car>(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() { }
diff --git a/src/test/ui/associated-type/associated-type-projection-from-supertrait.stderr b/src/test/ui/associated-type/associated-type-projection-from-supertrait.stderr
deleted file mode 100644 (file)
index 07f2076..0000000
+++ /dev/null
@@ -1,27 +0,0 @@
-error[E0308]: mismatched types
-  --> $DIR/associated-type-projection-from-supertrait.rs:27:23
-   |
-LL | fn b() { dent(ModelT, Blue); }
-   |                       ^^^^ expected struct `Black`, found struct `Blue`
-
-error[E0308]: mismatched types
-  --> $DIR/associated-type-projection-from-supertrait.rs:28:23
-   |
-LL | fn c() { dent(ModelU, Black); }
-   |                       ^^^^^ expected struct `Blue`, found struct `Black`
-
-error[E0308]: mismatched types
-  --> $DIR/associated-type-projection-from-supertrait.rs:32:28
-   |
-LL | fn f() { ModelT.chip_paint(Blue); }
-   |                            ^^^^ expected struct `Black`, found struct `Blue`
-
-error[E0308]: mismatched types
-  --> $DIR/associated-type-projection-from-supertrait.rs:33:28
-   |
-LL | fn g() { ModelU.chip_paint(Black); }
-   |                            ^^^^^ expected struct `Blue`, found struct `Black`
-
-error: aborting due to 4 previous errors
-
-For more information about this error, try `rustc --explain E0308`.
diff --git a/src/test/ui/associated-types/associated-type-projection-ambig-between-bound-and-where-clause.rs b/src/test/ui/associated-types/associated-type-projection-ambig-between-bound-and-where-clause.rs
new file mode 100644 (file)
index 0000000..c85d41c
--- /dev/null
@@ -0,0 +1,42 @@
+// 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 Box {
+    type Color;
+
+    fn mail(&self) {  }
+}
+
+fn a<C:Vehicle+Box>(_: C::Color) {
+    //~^ ERROR ambiguous associated type `Color` in bounds of `C`
+}
+
+fn b<C>(_: C::Color) where C : Vehicle+Box {
+    //~^ ERROR ambiguous associated type `Color` in bounds of `C`
+}
+
+fn c<C>(_: C::Color) where C : Vehicle, C : Box {
+    //~^ ERROR ambiguous associated type `Color` in bounds of `C`
+}
+
+struct D<X>;
+impl<X> D<X> where X : Vehicle {
+    fn d(&self, _: X::Color) where X : Box { }
+    //~^ ERROR ambiguous associated type `Color` in bounds of `X`
+}
+
+trait E<X:Vehicle> {
+    fn e(&self, _: X::Color) where X : Box;
+    //~^ ERROR ambiguous associated type `Color` in bounds of `X`
+
+    fn f(&self, _: X::Color) where X : Box { }
+    //~^ ERROR ambiguous associated type `Color` in bounds of `X`
+}
+
+pub fn main() { }
diff --git a/src/test/ui/associated-types/associated-type-projection-ambig-between-bound-and-where-clause.stderr b/src/test/ui/associated-types/associated-type-projection-ambig-between-bound-and-where-clause.stderr
new file mode 100644 (file)
index 0000000..6de8459
--- /dev/null
@@ -0,0 +1,129 @@
+error[E0221]: ambiguous associated type `Color` in bounds of `C`
+  --> $DIR/associated-type-projection-ambig-between-bound-and-where-clause.rs:16:24
+   |
+LL |     type Color;
+   |     ----------- ambiguous `Color` from `Vehicle`
+...
+LL |     type Color;
+   |     ----------- ambiguous `Color` from `Box`
+...
+LL | fn a<C:Vehicle+Box>(_: C::Color) {
+   |                        ^^^^^^^^ ambiguous associated type `Color`
+   |
+help: use fully qualified syntax to disambiguate
+   |
+LL | fn a<C:Vehicle+Box>(_: <C as Box>::Color) {
+   |                        ^^^^^^^^^^^^^^^^^
+help: use fully qualified syntax to disambiguate
+   |
+LL | fn a<C:Vehicle+Box>(_: <C as Vehicle>::Color) {
+   |                        ^^^^^^^^^^^^^^^^^^^^^
+
+error[E0221]: ambiguous associated type `Color` in bounds of `C`
+  --> $DIR/associated-type-projection-ambig-between-bound-and-where-clause.rs:20:12
+   |
+LL |     type Color;
+   |     ----------- ambiguous `Color` from `Vehicle`
+...
+LL |     type Color;
+   |     ----------- ambiguous `Color` from `Box`
+...
+LL | fn b<C>(_: C::Color) where C : Vehicle+Box {
+   |            ^^^^^^^^ ambiguous associated type `Color`
+   |
+help: use fully qualified syntax to disambiguate
+   |
+LL | fn b<C>(_: <C as Box>::Color) where C : Vehicle+Box {
+   |            ^^^^^^^^^^^^^^^^^
+help: use fully qualified syntax to disambiguate
+   |
+LL | fn b<C>(_: <C as Vehicle>::Color) where C : Vehicle+Box {
+   |            ^^^^^^^^^^^^^^^^^^^^^
+
+error[E0221]: ambiguous associated type `Color` in bounds of `C`
+  --> $DIR/associated-type-projection-ambig-between-bound-and-where-clause.rs:24:12
+   |
+LL |     type Color;
+   |     ----------- ambiguous `Color` from `Vehicle`
+...
+LL |     type Color;
+   |     ----------- ambiguous `Color` from `Box`
+...
+LL | fn c<C>(_: C::Color) where C : Vehicle, C : Box {
+   |            ^^^^^^^^ ambiguous associated type `Color`
+   |
+help: use fully qualified syntax to disambiguate
+   |
+LL | fn c<C>(_: <C as Box>::Color) where C : Vehicle, C : Box {
+   |            ^^^^^^^^^^^^^^^^^
+help: use fully qualified syntax to disambiguate
+   |
+LL | fn c<C>(_: <C as Vehicle>::Color) where C : Vehicle, C : Box {
+   |            ^^^^^^^^^^^^^^^^^^^^^
+
+error[E0221]: ambiguous associated type `Color` in bounds of `X`
+  --> $DIR/associated-type-projection-ambig-between-bound-and-where-clause.rs:35:20
+   |
+LL |     type Color;
+   |     ----------- ambiguous `Color` from `Vehicle`
+...
+LL |     type Color;
+   |     ----------- ambiguous `Color` from `Box`
+...
+LL |     fn e(&self, _: X::Color) where X : Box;
+   |                    ^^^^^^^^ ambiguous associated type `Color`
+   |
+help: use fully qualified syntax to disambiguate
+   |
+LL |     fn e(&self, _: <X as Box>::Color) where X : Box;
+   |                    ^^^^^^^^^^^^^^^^^
+help: use fully qualified syntax to disambiguate
+   |
+LL |     fn e(&self, _: <X as Vehicle>::Color) where X : Box;
+   |                    ^^^^^^^^^^^^^^^^^^^^^
+
+error[E0221]: ambiguous associated type `Color` in bounds of `X`
+  --> $DIR/associated-type-projection-ambig-between-bound-and-where-clause.rs:38:20
+   |
+LL |     type Color;
+   |     ----------- ambiguous `Color` from `Vehicle`
+...
+LL |     type Color;
+   |     ----------- ambiguous `Color` from `Box`
+...
+LL |     fn f(&self, _: X::Color) where X : Box { }
+   |                    ^^^^^^^^ ambiguous associated type `Color`
+   |
+help: use fully qualified syntax to disambiguate
+   |
+LL |     fn f(&self, _: <X as Box>::Color) where X : Box { }
+   |                    ^^^^^^^^^^^^^^^^^
+help: use fully qualified syntax to disambiguate
+   |
+LL |     fn f(&self, _: <X as Vehicle>::Color) where X : Box { }
+   |                    ^^^^^^^^^^^^^^^^^^^^^
+
+error[E0221]: ambiguous associated type `Color` in bounds of `X`
+  --> $DIR/associated-type-projection-ambig-between-bound-and-where-clause.rs:30:20
+   |
+LL |     type Color;
+   |     ----------- ambiguous `Color` from `Vehicle`
+...
+LL |     type Color;
+   |     ----------- ambiguous `Color` from `Box`
+...
+LL |     fn d(&self, _: X::Color) where X : Box { }
+   |                    ^^^^^^^^ ambiguous associated type `Color`
+   |
+help: use fully qualified syntax to disambiguate
+   |
+LL |     fn d(&self, _: <X as Box>::Color) where X : Box { }
+   |                    ^^^^^^^^^^^^^^^^^
+help: use fully qualified syntax to disambiguate
+   |
+LL |     fn d(&self, _: <X as Vehicle>::Color) where X : Box { }
+   |                    ^^^^^^^^^^^^^^^^^^^^^
+
+error: aborting due to 6 previous errors
+
+For more information about this error, try `rustc --explain E0221`.
diff --git a/src/test/ui/associated-types/associated-type-projection-from-multiple-supertraits.rs b/src/test/ui/associated-types/associated-type-projection-from-multiple-supertraits.rs
new file mode 100644 (file)
index 0000000..df19332
--- /dev/null
@@ -0,0 +1,43 @@
+// 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 Box {
+    type Color;
+    //
+    fn mail(&self) {  }
+}
+
+pub trait BoxCar : Box + Vehicle {
+}
+
+fn dent<C:BoxCar>(c: C, color: C::Color) {
+    //~^ ERROR ambiguous associated type `Color` in bounds of `C`
+}
+
+fn dent_object<COLOR>(c: dyn BoxCar<Color=COLOR>) {
+    //~^ ERROR ambiguous associated type
+    //~| ERROR the value of the associated types
+}
+
+fn paint<C:BoxCar>(c: C, d: C::Color) {
+    //~^ ERROR ambiguous associated type `Color` in bounds of `C`
+}
+
+fn dent_object_2<COLOR>(c: dyn BoxCar) where <dyn BoxCar as Vehicle>::Color = COLOR {
+    //~^ ERROR the value of the associated types
+    //~| ERROR equality constraints are not yet supported in `where` clauses
+}
+
+fn dent_object_3<X, COLOR>(c: X)
+where X: BoxCar,
+    X: Vehicle<Color = COLOR>,
+    X: Box<Color = COLOR>
+{} // OK!
+
+pub fn main() { }
diff --git a/src/test/ui/associated-types/associated-type-projection-from-multiple-supertraits.stderr b/src/test/ui/associated-types/associated-type-projection-from-multiple-supertraits.stderr
new file mode 100644 (file)
index 0000000..b6a8817
--- /dev/null
@@ -0,0 +1,100 @@
+error: equality constraints are not yet supported in `where` clauses
+  --> $DIR/associated-type-projection-from-multiple-supertraits.rs:32:46
+   |
+LL | fn dent_object_2<COLOR>(c: dyn BoxCar) where <dyn BoxCar as Vehicle>::Color = COLOR {
+   |                                              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not supported
+   |
+   = note: see issue #20041 <https://github.com/rust-lang/rust/issues/20041> for more information
+
+error[E0221]: ambiguous associated type `Color` in bounds of `C`
+  --> $DIR/associated-type-projection-from-multiple-supertraits.rs:19:32
+   |
+LL |     type Color;
+   |     ----------- ambiguous `Color` from `Vehicle`
+...
+LL |     type Color;
+   |     ----------- ambiguous `Color` from `Box`
+...
+LL | fn dent<C:BoxCar>(c: C, color: C::Color) {
+   |                                ^^^^^^^^ ambiguous associated type `Color`
+   |
+help: use fully qualified syntax to disambiguate
+   |
+LL | fn dent<C:BoxCar>(c: C, color: <C as Box>::Color) {
+   |                                ^^^^^^^^^^^^^^^^^
+help: use fully qualified syntax to disambiguate
+   |
+LL | fn dent<C:BoxCar>(c: C, color: <C as Vehicle>::Color) {
+   |                                ^^^^^^^^^^^^^^^^^^^^^
+
+error[E0222]: ambiguous associated type `Color` in bounds of `BoxCar`
+  --> $DIR/associated-type-projection-from-multiple-supertraits.rs:23:37
+   |
+LL |     type Color;
+   |     ----------- ambiguous `Color` from `Vehicle`
+...
+LL |     type Color;
+   |     ----------- ambiguous `Color` from `Box`
+...
+LL | fn dent_object<COLOR>(c: dyn BoxCar<Color=COLOR>) {
+   |                                     ^^^^^^^^^^^ ambiguous associated type `Color`
+   |
+   = help: consider introducing a new type parameter `T` and adding `where` constraints:
+               where
+                   T: BoxCar,
+                   T: Box::Color = COLOR,
+                   T: Vehicle::Color = COLOR
+
+error[E0191]: the value of the associated types `Color` (from trait `Box`), `Color` (from trait `Vehicle`) must be specified
+  --> $DIR/associated-type-projection-from-multiple-supertraits.rs:23:30
+   |
+LL |     type Color;
+   |     ----------- `Vehicle::Color` defined here
+...
+LL |     type Color;
+   |     ----------- `Box::Color` defined here
+...
+LL | fn dent_object<COLOR>(c: dyn BoxCar<Color=COLOR>) {
+   |                              ^^^^^^^^^^^^^^^^^^^ associated types `Color` (from trait `Vehicle`), `Color` (from trait `Box`) must be specified
+   |
+   = help: consider introducing a new type parameter, adding `where` constraints using the fully-qualified path to the associated types
+
+error[E0221]: ambiguous associated type `Color` in bounds of `C`
+  --> $DIR/associated-type-projection-from-multiple-supertraits.rs:28:29
+   |
+LL |     type Color;
+   |     ----------- ambiguous `Color` from `Vehicle`
+...
+LL |     type Color;
+   |     ----------- ambiguous `Color` from `Box`
+...
+LL | fn paint<C:BoxCar>(c: C, d: C::Color) {
+   |                             ^^^^^^^^ ambiguous associated type `Color`
+   |
+help: use fully qualified syntax to disambiguate
+   |
+LL | fn paint<C:BoxCar>(c: C, d: <C as Box>::Color) {
+   |                             ^^^^^^^^^^^^^^^^^
+help: use fully qualified syntax to disambiguate
+   |
+LL | fn paint<C:BoxCar>(c: C, d: <C as Vehicle>::Color) {
+   |                             ^^^^^^^^^^^^^^^^^^^^^
+
+error[E0191]: the value of the associated types `Color` (from trait `Box`), `Color` (from trait `Vehicle`) must be specified
+  --> $DIR/associated-type-projection-from-multiple-supertraits.rs:32:32
+   |
+LL |     type Color;
+   |     ----------- `Vehicle::Color` defined here
+...
+LL |     type Color;
+   |     ----------- `Box::Color` defined here
+...
+LL | fn dent_object_2<COLOR>(c: dyn BoxCar) where <dyn BoxCar as Vehicle>::Color = COLOR {
+   |                                ^^^^^^ associated types `Color` (from trait `Vehicle`), `Color` (from trait `Box`) must be specified
+   |
+   = help: consider introducing a new type parameter, adding `where` constraints using the fully-qualified path to the associated types
+
+error: aborting due to 6 previous errors
+
+Some errors have detailed explanations: E0191, E0221, E0222.
+For more information about an error, try `rustc --explain E0191`.
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 (file)
index 0000000..7e05bcd
--- /dev/null
@@ -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:Car>(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() { }
diff --git a/src/test/ui/associated-types/associated-type-projection-from-supertrait.stderr b/src/test/ui/associated-types/associated-type-projection-from-supertrait.stderr
new file mode 100644 (file)
index 0000000..07f2076
--- /dev/null
@@ -0,0 +1,27 @@
+error[E0308]: mismatched types
+  --> $DIR/associated-type-projection-from-supertrait.rs:27:23
+   |
+LL | fn b() { dent(ModelT, Blue); }
+   |                       ^^^^ expected struct `Black`, found struct `Blue`
+
+error[E0308]: mismatched types
+  --> $DIR/associated-type-projection-from-supertrait.rs:28:23
+   |
+LL | fn c() { dent(ModelU, Black); }
+   |                       ^^^^^ expected struct `Blue`, found struct `Black`
+
+error[E0308]: mismatched types
+  --> $DIR/associated-type-projection-from-supertrait.rs:32:28
+   |
+LL | fn f() { ModelT.chip_paint(Blue); }
+   |                            ^^^^ expected struct `Black`, found struct `Blue`
+
+error[E0308]: mismatched types
+  --> $DIR/associated-type-projection-from-supertrait.rs:33:28
+   |
+LL | fn g() { ModelU.chip_paint(Black); }
+   |                            ^^^^^ expected struct `Blue`, found struct `Black`
+
+error: aborting due to 4 previous errors
+
+For more information about this error, try `rustc --explain E0308`.