+++ /dev/null
-// 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() { }
+++ /dev/null
-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`.
+++ /dev/null
-// 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() { }
+++ /dev/null
-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`.
+++ /dev/null
-// 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() { }
+++ /dev/null
-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`.
--- /dev/null
+// 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() { }
--- /dev/null
+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`.
--- /dev/null
+// 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() { }
--- /dev/null
+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`.
--- /dev/null
+// 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() { }
--- /dev/null
+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`.