-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Compiler hangs during recursive monomorphisation #39684
Comments
This is actually a monomorphisation issue, though I'm surprised it hangs since we do try to detect recursive monomorphisations too. |
So this seems to be related to resolving the |
After waiting for a little bit, this is the log I get. So I think part of the problem here is that we slowly recurse; that is, each step appears to take quite a while, so our recursion depth isn't really growing fast.
|
Hello, pub enum Equation<A, B> {
Mul(A, B),
Value(A),
}
impl<A, B> Default for Equation<A, B>
where
A: Default,
{
fn default() -> Self {
Equation::Value(A::default())
}
}
impl<A, B, T> From<T> for Equation<Equation<A, B>, Equation<A, B>>
where
T: ToString,
Equation<A, B>: From<T>,
A: Default,
{
fn from(input: T) -> Self {
let left: Equation<A, B> = input.to_string().into();
let right = Equation::default();
let result: Equation<Equation<A, B>, Equation<A, B>> = Equation::Mul(left, right);
return result;
}
}
fn main() {
println!("nothing to see here");
} Here is playground link. |
@Mark-Simulacrum could the slow part being caused by exponential blowup? We can only reproduce with infinite recursion currently, so we can't easily confirm what's going on here. However, it's possible something like breadth-first search was used and causing the blowup here. Anyway, here's a log dump (from debug-assertions build) for examination: |
This is exponential. Have fun.
|
This tracks down to the same cause as #38528 (comment). Random suspension stack trace:
|
With PoC in #48296 this resolves in finite time. The error is too silly though. `-Z time-passes` with silly error message
|
Fix exponential projection complexity on nested types This implements solution 1 from #38528 (comment). The code quality is currently extremely poor, but we can improve them during review. Blocking issues: - we probably don't want a quadratic deduplication for obligations. - is there an alternative to deduplication? Based on #48315. Needs changelog. Noticable improvement on compile time is expected. Fix #38528 Close #39684 Close #43757
…sakis Fix exponential projection complexity on nested types This implements solution 1 from rust-lang#38528 (comment). The code quality is currently extremely poor, but we can improve them during review. Blocking issues: - we probably don't want a quadratic deduplication for obligations. - is there an alternative to deduplication? Based on rust-lang#48315. Needs changelog. Noticable improvement on compile time is expected. Fix rust-lang#38528 Close rust-lang#39684 Close rust-lang#43757
This code causes compiler to be stuck wasting CPU cycles, instead of printing some kind of recursion limit error.
The text was updated successfully, but these errors were encountered: