-
Notifications
You must be signed in to change notification settings - Fork 182
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
Recursive solver hangs on cyclic traits #773
Comments
Slightly simpler repro, this one from rust-lang/rust-analyzer#12667. Hangs even with default depth. #[test]
fn ra_12667() {
test! {
program {
trait Clone { }
trait A {
type X: B;
}
trait B {
type Y: A<X = Self>;
}
}
goal {
exists<T> {
if (T: A) {
<T as A>::X: Clone
}
}
} yields[SolverChoice::recursive_default()] {
expect![["No possible solution"]]
}
}
} |
So it's expanding the goals like this:
which replaces Do we need to start inspecting substitutions/goals for such repetitions, or is there a better solution? |
I ran into another variant of this problem. The following code also hangs with pub trait Foo {
type Bar: Bar<Foo = Self>;
}
pub trait Bar {
type Foo: Foo<Bar = Self>;
}
type Inner<A> = <<A as Foo>::Bar as Bar>::Foo;
fn inner<A: Foo>(val: Inner<A>) -> A {
val
}
fn outer<A: Foo>(val: Inner<A>) -> A {
let ret = inner(val);
ret
} I think this is the same underlying problem, but I also wanted to share this variation to trigger the problem. |
Found in rust-analyzer#12897, the following test causes the recursive solver to loop:
Output:
The text was updated successfully, but these errors were encountered: