-
-
Notifications
You must be signed in to change notification settings - Fork 14.8k
Hang on overflowing evaluating the requirement with extra generic types #127315
Copy link
Copy link
Open
Labels
A-inferenceArea: Type inferenceArea: Type inferenceA-trait-systemArea: Trait systemArea: Trait systemC-bugCategory: This is a bug.Category: This is a bug.I-hangIssue: The compiler never terminates, due to infinite loops, deadlock, livelock, etc.Issue: The compiler never terminates, due to infinite loops, deadlock, livelock, etc.P-mediumMedium priorityMedium priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.fixed-by-next-solverFixed by the next-generation trait solver, `-Znext-solver`.Fixed by the next-generation trait solver, `-Znext-solver`.regression-from-stable-to-stablePerformance or correctness regression from one stable version to another.Performance or correctness regression from one stable version to another.
Metadata
Metadata
Assignees
Labels
A-inferenceArea: Type inferenceArea: Type inferenceA-trait-systemArea: Trait systemArea: Trait systemC-bugCategory: This is a bug.Category: This is a bug.I-hangIssue: The compiler never terminates, due to infinite loops, deadlock, livelock, etc.Issue: The compiler never terminates, due to infinite loops, deadlock, livelock, etc.P-mediumMedium priorityMedium priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.fixed-by-next-solverFixed by the next-generation trait solver, `-Znext-solver`.Fixed by the next-generation trait solver, `-Znext-solver`.regression-from-stable-to-stablePerformance or correctness regression from one stable version to another.Performance or correctness regression from one stable version to another.
Type
Fields
Give feedbackNo fields configured for issues without a type.
Projects
Status
Todo
First of all I would like to make apology ahead if this is a duplicated case. It's really hard to describe such abstract pattern and look for it from previous issues. At least it is reproducible on nightly.
I tried this code:
I expected to see this happen: compile terminates.
Instead, this happened:
And it hangs here forever. The memory gradually goes high, not fast but eventually memory will be exhausted.
What's more worrying is that on stable channel, the rustc process is not exiting even after ctrl-c is pressed and the shell gets back to prompt (which makes it feels like exited). This is probably a general issue not relevant to this case.
Meta
rustc --version --verbose:Also reproduced on nightly channel
Backtrace
Related minor issues.
Removing either
Afrom traitOuterT<A>orUfromOuter<U, _>makes the compilation terminates. If choose to removeAthe compilation will fail withThe
help:line is not helpful here, as in this case the recursion is obviously infinite.If further remove the
O: OuterTbound on line 9 and fill the type placeholder on line 32 (e.g.Outer::<(), InnerHelper>, the code will compile, which is possibly unexpected since theOuter<U, _>struct still has an unused generic typeU.Notes. I have been playing with this seemingly weird
Helpertrait because in the original codeInnerneed to takeOuteras an generic parameter, andHelperacts as a "type level function" to passSelfout ofOuter. During case reduction the generic onInneris reduced. Not sure whether the wholeHelpercan also be reduced away as well, a simple attempt did not succeed.