Weird compiler issue - overflow evaluating the requirement

I’ve hit an interesting issue that might be a compiler bug. It’s elusive and it’s hard to produce minimal example because the issue seems to appear and disappear and same code can produce different result locally and in the playground, but I managed to get a repro in the playground.

https://play.rust-lang.org/?version=nightly&mode=debug&edition=2018&gist=06dcbc5a8f4348f31d8504c09a40d7b8

Running this code as ‘test’ produces

error[E0275]: overflow evaluating the requirement `&Matrix<_>: std::ops::Mul<&Matrix<_>>`

What is puzzling me most, small changes like removing the unused ‘Sub’ import make the issue go away! Is this an expected behaviour?

2 Likes

See also Strange rust compiler recursion for a similar issue. This is indeed a shortcoming of the compiler, but it occurs if there is an unmet requirement.

But why does removing seemingly unrelated code fix the issue? I would understand that unment requirement causes some recursive check that overflows if it was consistent.

This definitely is a bug, and I think the compiler team is aware of this issue in principle. My understanding is that the current version of the constraint solver can’t be fixed easily, and that chalk is eventually meant to fix this and similar issues, but my understanding isn’t very deep.

3 Likes

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.