about summary refs log tree commit diff
path: root/src/rustllvm/RustWrapper.cpp
diff options
context:
space:
mode:
authorRalf Jung <post@ralfj.de>2020-05-30 13:45:10 +0200
committerGitHub <noreply@github.com>2020-05-30 13:45:10 +0200
commitf96e3e206928d4214997c5585ab9f45318d1d8c6 (patch)
treeb1756709379ef05e6a396282cd3069844bd5074d /src/rustllvm/RustWrapper.cpp
parent43ae54de9c45aff72c293e4a469f0bb9a071979e (diff)
parenta54ed872cb79529195f4b02910be823a75f3da22 (diff)
downloadrust-f96e3e206928d4214997c5585ab9f45318d1d8c6.tar.gz
rust-f96e3e206928d4214997c5585ab9f45318d1d8c6.zip
Rollup merge of #72540 - davidtwco:issue-67552-mono-collector-comparison, r=varkor
mir: adjust conditional in recursion limit check

Fixes #67552.

This PR adjusts the condition used in the recursion limit check of
the monomorphization collector, from `>` to `>=`.

In #67552, the test case had infinite indirect recursion, repeating a
handful of functions (from the perspective of the monomorphization
collector): `rec` -> `identity` -> `Iterator::count` -> `Iterator::fold`
-> `Iterator::next` -> `rec`.

During this process, `resolve_associated_item` was invoked for
`Iterator::fold` (during the construction of an `Instance`), and
ICE'd due to substitutions needing inference. However, previous
iterations of this recursion would have called this function for
`Iterator::fold` - and did! - and succeeded in doing so (trivially
checkable from debug logging, `()` is present where `_` is in the substs
of the failing execution).

The expected outcome of this test case would be a recursion limit error
(which is present when the `identity` fn indirection is removed), and
the recursion depth of `rec` is increasing (other functions finish
collecting their neighbours and thus have their recursion depths reset).

When the ICE occurs, the recursion depth of `rec` is 256 (which matches
the recursion limit), which suggests perhaps that a different part of
the compiler is using a `>=` comparison and returning a different result
on this recursion rather than what it returned in every previous
recursion, thus stopping the monomorphization collector from reporting
an error on the next recursion, where `recursion_depth_of_rec > 256`
would have been true.

With grep and some educated guesses, we can determine that
the recursion limit check at line 818 in
`src/librustc_trait_selection/traits/project.rs` is the other check that
is using a different comparison. Modifying either comparison to be `>` or
`>=` respectively will fix the error, but changing the monomorphization
collector produces the nicer error.
Diffstat (limited to 'src/rustllvm/RustWrapper.cpp')
0 files changed, 0 insertions, 0 deletions