Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Infinite Loop when Evaluating Recursive Type #122443

Open
entropylost opened this issue Mar 13, 2024 · 0 comments
Open

Infinite Loop when Evaluating Recursive Type #122443

entropylost opened this issue Mar 13, 2024 · 0 comments
Labels
A-associated-items Area: Associated items such as associated types and consts. A-traits Area: Trait system C-bug Category: This is a bug. fixed-by-next-solver Fixed by the next-generation trait solver, `-Znext-solver`. I-hang Issue: The compiler never terminates, due to infinite loops, deadlock, livelock, etc. T-types Relevant to the types team, which will review and decide on the PR/issue.

Comments

@entropylost
Copy link

I tried the code:

trait Access {
    type Downcast: Access;
}

trait Mapping<X: Access> {}

trait AllowedMappingLoopback<X: Access> {
    type Chain: AllowedMapping<X::Downcast>;
}
impl<X: Access> AllowedMappingLoopback<X> for X
where
    X: AllowedMapping<X::Downcast>,
{
    type Chain = X;
}

trait AllowedMapping<X: Access>: AllowedMappingLoopback<X, Chain = Self> {}
impl<X: Access, T> AllowedMapping<X> for T where
    T: Mapping<X> + AllowedMappingLoopback<X, Chain = Self>
{
}

fn do_thing_with_allowed<X: Access>(mapping: impl AllowedMapping<X>) {}

struct BasicMapping;

fn test() {
    do_thing_with_allowed(BasicMapping);
}

This results in an infinite loop within the compiler, within both the latest nightly (1.78.0 (2024-03-12)) and stable (1.76.0).
(see playground)

@entropylost entropylost added the C-bug Category: This is a bug. label Mar 13, 2024
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Mar 13, 2024
@fmease fmease added A-traits Area: Trait system A-associated-items Area: Associated items such as associated types and consts. I-hang Issue: The compiler never terminates, due to infinite loops, deadlock, livelock, etc. T-types Relevant to the types team, which will review and decide on the PR/issue. fixed-by-next-solver Fixed by the next-generation trait solver, `-Znext-solver`. and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Mar 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-associated-items Area: Associated items such as associated types and consts. A-traits Area: Trait system C-bug Category: This is a bug. fixed-by-next-solver Fixed by the next-generation trait solver, `-Znext-solver`. I-hang Issue: The compiler never terminates, due to infinite loops, deadlock, livelock, etc. T-types Relevant to the types team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

3 participants