Hang on overflowing evaluating the requirement with extra generic types #127315
Labels
A-inference
Area: Type inference
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.
P-medium
Medium priority
regression-from-stable-to-stable
Performance or correctness regression from one stable version to another.
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
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
A
from traitOuterT<A>
orU
fromOuter<U, _>
makes the compilation terminates. If choose to removeA
the compilation will fail withThe
help:
line is not helpful here, as in this case the recursion is obviously infinite.If further remove the
O: OuterT
bound 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
Helper
trait because in the original codeInner
need to takeOuter
as an generic parameter, andHelper
acts as a "type level function" to passSelf
out ofOuter
. During case reduction the generic onInner
is reduced. Not sure whether the wholeHelper
can also be reduced away as well, a simple attempt did not succeed.The text was updated successfully, but these errors were encountered: