diff --git a/tests/ui/associated-types/nested-assoc-type-projection-ice-109864.rs b/tests/ui/associated-types/nested-assoc-type-projection-ice-109864.rs new file mode 100644 index 0000000000000..ae55712c50a93 --- /dev/null +++ b/tests/ui/associated-types/nested-assoc-type-projection-ice-109864.rs @@ -0,0 +1,39 @@ +//! Regression test for . +//! +//! Deeply nested associated-type projections used to ICE with "type variables +//! should not be hashed" — but only under incremental compilation. They should now +//! produce ordinary trait-bound errors instead of crashing. + +//@ incremental + +struct S; +struct S2

(); //~ ERROR type parameter `P` is never used + +trait Foo { + type Out; +} + +trait Bar { + type Out; +} + +trait Qux { + type Out; +} + +trait Fuzz { + type Out; +} + +impl, B> Fuzz> for S2 { + type Out = <>::Out as Bar< + //~^ ERROR the trait bound `>::Out: Qux` is not satisfied + //~| ERROR the trait bound `>::Out: Bar, _>` is not satisfied + //~| ERROR the trait bound `>::Out: Bar, _>` is not satisfied + S2, + <<>::Out as Qux>::Out as Fuzz>>::Out, + //~^ ERROR the trait bound `>::Out: Qux` is not satisfied + >>::Out; +} + +fn main() {} diff --git a/tests/ui/associated-types/nested-assoc-type-projection-ice-109864.stderr b/tests/ui/associated-types/nested-assoc-type-projection-ice-109864.stderr new file mode 100644 index 0000000000000..fdf55aa4c2bdb --- /dev/null +++ b/tests/ui/associated-types/nested-assoc-type-projection-ice-109864.stderr @@ -0,0 +1,65 @@ +error[E0392]: type parameter `P` is never used + --> $DIR/nested-assoc-type-projection-ice-109864.rs:10:11 + | +LL | struct S2

(); + | ^ unused type parameter + | + = help: consider removing `P`, referring to it in a field, or using a marker such as `PhantomData` + = help: if you intended `P` to be a const parameter, use `const P: /* Type */` instead + +error[E0277]: the trait bound `>::Out: Qux` is not satisfied + --> $DIR/nested-assoc-type-projection-ice-109864.rs:29:16 + | +LL | type Out = <>::Out as Bar< + | ________________^ +... | +LL | | >>::Out; + | |___________^ the trait `Qux` is not implemented for `>::Out` + | +help: consider further restricting the associated type + | +LL | impl, B> Fuzz> for S2 where >::Out: Qux { + | ++++++++++++++++++++++++++++++++ + +error[E0277]: the trait bound `>::Out: Bar, _>` is not satisfied + --> $DIR/nested-assoc-type-projection-ice-109864.rs:29:16 + | +LL | type Out = <>::Out as Bar< + | ________________^ +... | +LL | | >>::Out; + | |___________^ the trait `Bar, _>` is not implemented for `>::Out` + | +help: this trait has no implementations, consider adding one + --> $DIR/nested-assoc-type-projection-ice-109864.rs:16:1 + | +LL | trait Bar { + | ^^^^^^^^^^^^^^^ + +error[E0277]: the trait bound `>::Out: Qux` is not satisfied + --> $DIR/nested-assoc-type-projection-ice-109864.rs:34:10 + | +LL | <<>::Out as Qux>::Out as Fuzz>>::Out, + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Qux` is not implemented for `>::Out` + | +help: consider further restricting the associated type + | +LL | impl, B> Fuzz> for S2 where >::Out: Qux { + | ++++++++++++++++++++++++++++++++ + +error[E0277]: the trait bound `>::Out: Bar, _>` is not satisfied + --> $DIR/nested-assoc-type-projection-ice-109864.rs:29:5 + | +LL | type Out = <>::Out as Bar< + | ^^^^^^^^ the trait `Bar, _>` is not implemented for `>::Out` + | +help: this trait has no implementations, consider adding one + --> $DIR/nested-assoc-type-projection-ice-109864.rs:16:1 + | +LL | trait Bar { + | ^^^^^^^^^^^^^^^ + +error: aborting due to 5 previous errors + +Some errors have detailed explanations: E0277, E0392. +For more information about an error, try `rustc --explain E0277`.