Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 59 additions & 0 deletions tests/ui/specialization/auxiliary/impls-cycle-90817.rs
Original file line number Diff line number Diff line change
@@ -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<R> {}

impl<T> Reduce<Base> for T {}

impl<T, R> Reduce<R> for T
where
R: Reducible,
T: Reduce<R::Reduced>,
{
}

pub fn reduce<R>(_: R)
where
(): Reduce<R>,
{
}

pub trait Change<T> {
type Changed;
}

impl<T> Change<T> for () {
type Changed = T;
}

pub trait Split {
type First;
type Rest;
}

pub trait Combine<T> {}

impl<U> Combine<()> for U {}

impl<T, U> Combine<U> for T
where
U: Split,
Self: Change<U::First>,
<Self as Change<U::First>>::Changed: Combine<U::Rest>,
{
}

pub fn combine<T>(_: T)
where
(): Combine<T>,
{
}
12 changes: 12 additions & 0 deletions tests/ui/specialization/cross-crate-impls-cycle-90817.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
//@ aux-build:impls-cycle-90817.rs
//@ check-pass
//! Regression test for <https://github.com/rust-lang/rust/issues/90817>.
//! 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(());
}
Loading