Description
The new fulfillment context from #30533 can detect and extract cycles in the trait resolution graph, but (for the most part) it still reports them the same way as any other overflow. We can do a lot better. In fact, it does do a lot better, for the Sized
trait in particular. This machinery could surely be adopted:
- We should be able to print out the full cycle.
- We should be able to avoid suggesting increasing the overflow limit, as that will not help.
We could probably stop aborting compilation too, but it'd be just a touch trickier. I think the most correct thing would be to refactor the fulfillment context interface to transmit back "overflow" as a distinct category from other errors. This is because overflow seems different from the absence of an impl. OTOH, I'm not sure if this matters in practice, particularly if we adapt the way we handle negative reasoning. Perhaps the absence of an impl and overflow can both be treated as an error in that case.