diff --git a/tests/ui/specialization/auxiliary/impls-cycle-90817.rs b/tests/ui/specialization/auxiliary/impls-cycle-90817.rs new file mode 100644 index 0000000000000..9896e498f9996 --- /dev/null +++ b/tests/ui/specialization/auxiliary/impls-cycle-90817.rs @@ -0,0 +1,59 @@ +pub trait Reducible { + type Reduced; +} + +pub struct Base; + +pub struct Higher; + +impl Reducible for Higher { + type Reduced = Base; +} + +pub trait Reduce {} + +impl Reduce for T {} + +impl Reduce for T +where + R: Reducible, + T: Reduce, +{ +} + +pub fn reduce(_: R) +where + (): Reduce, +{ +} + +pub trait Change { + type Changed; +} + +impl Change for () { + type Changed = T; +} + +pub trait Split { + type First; + type Rest; +} + +pub trait Combine {} + +impl Combine<()> for U {} + +impl Combine for T +where + U: Split, + Self: Change, + >::Changed: Combine, +{ +} + +pub fn combine(_: T) +where + (): Combine, +{ +} diff --git a/tests/ui/specialization/cross-crate-impls-cycle-90817.rs b/tests/ui/specialization/cross-crate-impls-cycle-90817.rs new file mode 100644 index 0000000000000..6bc787f1c3b33 --- /dev/null +++ b/tests/ui/specialization/cross-crate-impls-cycle-90817.rs @@ -0,0 +1,12 @@ +//@ aux-build:impls-cycle-90817.rs +//@ check-pass +//! Regression test for . +//! Checking whether these impls specialize one another used to hit a query +//! cycle (E0391) when the impls live in another crate. + +extern crate impls_cycle_90817; + +fn main() { + impls_cycle_90817::reduce(impls_cycle_90817::Higher); + impls_cycle_90817::combine(()); +}