Repository navigation
Compiler (effectively) hangs, regression from overflow error #93774
Description
pub enum Either<L, R> {
Left(L),
Right(R),
}
pub trait HasItem<'a, _Constraint = &'a Self> {
type Item;
}
pub type Item<'a, Self_> = <Self_ as HasItem<'a>>::Item;
pub trait LendingIterator: for<'a> HasItem<'a> {
fn next(&mut self) -> Option<Item<'_, Self>>;
}
impl<'a, A: 'a, B: 'a> HasItem<'a> for Either<A, B>
where A: LendingIterator, B: LendingIterator,
for<'b> B: HasItem<'b, Item = Item<'b, Self>>
{
type Item = Item<'a, Self>;
}
impl<A, B> LendingIterator for Either<A, B>
where A: LendingIterator, B: LendingIterator,
for<'b> B: HasItem<'b, Item = Item<'b, Self>>
{
fn next(&mut self) -> Option<Item<'_, Self>> {
match self {
Either::Left(iter) => iter.next(),
Either::Right(iter) => iter.next(),
}
}
}hangs since 1.56
error on 1.55
error[E0275]: overflow evaluating the requirement `for<'b> <B as HasItem<'b>>::Item == <Either<A, B> as HasItem<'b>>::Item`
--> <source>:16:24
|
6 | pub trait HasItem<'a, _Constraint = &'a Self> {
| --------------------------------------------- required by this bound in `HasItem`
...
16 | impl<'a, A: 'a, B: 'a> HasItem<'a> for Either<A, B>
| ^^^^^^^^^^^
|
note: required because of the requirements on the impl of `HasItem<'a>` for `Either<A, B>`
--> <source>:16:24
|
16 | impl<'a, A: 'a, B: 'a> HasItem<'a> for Either<A, B>
| ^^^^^^^^^^^ ^^^^^^^^^^^^
error[E0275]: overflow evaluating the requirement `for<'b> <B as HasItem<'b>>::Item == <Either<A, B> as HasItem<'b>>::Item`
--> <source>:23:12
|
12 | pub trait LendingIterator: for<'a> HasItem<'a> {
| ------------------- required by this bound in `LendingIterator`
...
23 | impl<A, B> LendingIterator for Either<A, B>
| ^^^^^^^^^^^^^^^
|
note: required because of the requirements on the impl of `for<'a> HasItem<'a>` for `Either<A, B>`
--> <source>:16:24
|
16 | impl<'a, A: 'a, B: 'a> HasItem<'a> for Either<A, B>
| ^^^^^^^^^^^ ^^^^^^^^^^^^
error[E0275]: overflow evaluating the requirement `for<'b> <B as HasItem<'b>>::Item == <Either<A, B> as HasItem<'b>>::Item`
--> <source>:20:5
|
20 | type Item = Item<'a, Self>;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
note: required because of the requirements on the impl of `HasItem<'a>` for `Either<A, B>`
--> <source>:16:24
|
16 | impl<'a, A: 'a, B: 'a> HasItem<'a> for Either<A, B>
| ^^^^^^^^^^^ ^^^^^^^^^^^^
error[E0275]: overflow evaluating the requirement `for<'b> <B as HasItem<'b>>::Item == <Either<A, B> as HasItem<'b>>::Item`
--> <source>:27:8
|
27 | fn next(&mut self) -> Option<Item<'_, Self>> {
| ^^^^
|
note: required because of the requirements on the impl of `HasItem<'_>` for `Either<A, B>`
--> <source>:16:24
|
16 | impl<'a, A: 'a, B: 'a> HasItem<'a> for Either<A, B>
| ^^^^^^^^^^^ ^^^^^^^^^^^^
error: aborting due to 4 previous errors
@rustbot label I-hang, regression-from-stable-to-stable, A-traits, A-lifetimes, E-needs-bisection, T-compiler
Edit:
“Hangs” means “runs for a wile on 100% CPU until I cancel it”. Who knows if it would ever terminate… actually, maybe I should test smaller recursion limits.
Note that this code example is not expected to compile successfully. Here’s a version that works / with the mistakes fixed. (The fixed version also works on some older Rust versions, including 1.55 and older.)
Edit2: Using smaller limits (like… around #![recursion_limit = "14"] it starts getting unbearably slow) reveals that this is apparently more like exponential-time slowdown rather than “actual” hanging.
@rustbot label -I-hang, +I-compiletime, +perf-regression
Activity
[-]Compiler hangs, regression from overflow error[/-][+]Compiler (effectively) hangs, regression from overflow error[/+]apiraino commentedon Feb 10, 2022
Assigning priority as discussed in the Zulip thread of the Prioritization Working Group.
@rustbot label -I-prioritize +P-high
Badel2 commentedon Feb 11, 2022
Run a bisect on this, 8d7707f is the first bad commit.
cargo-bisect-rustcwas only able to narrow it down to nightly-2021-08-26, but I checked the remaining range using git bisect.steffahn commentedon Aug 16, 2022
Let me remove the bisection label and mention the relevant PR #85499 (cc @jackh726)
@rustbot label -E-needs-bisection
pnkfelix commentedon Nov 11, 2022
Discussed in T-compiler P-high review
Reassigning to T-types to determine what to do, if anything, in response to this.
@rustbot label -T-compiler +T-types
cyrgani commentedon Jul 26, 2025
Bisection reveals that this was fixed in nightly-2023-03-09, between 1.69 and 1.70, and now errors directly instead:
Regression in nightly-2023-03-09
fetching https://static.rust-lang.org/dist/2023-03-08/channel-rust-nightly-git-commit-hash.txt
nightly manifest 2023-03-08: 40 B / 40 B [=============================================================================] 100.00 % 524.67 KB/s converted 2023-03-08 to e3dfeea
fetching https://static.rust-lang.org/dist/2023-03-09/channel-rust-nightly-git-commit-hash.txt
nightly manifest 2023-03-09: 40 B / 40 B [=============================================================================] 100.00 % 634.84 KB/s converted 2023-03-09 to 900c354
looking for regression commit between 2023-03-08 and 2023-03-09
fetching (via remote github) commits from max(e3dfeea, 2023-03-06) to 900c354
ending github query because we found starting sha: e3dfeea
get_commits_between returning commits, len: 6
commit[0] 2023-03-07: Auto merge of #108167 - Zoxc:query-config-instance-slim, r=cjgillot
commit[1] 2023-03-07: Auto merge of #108877 - matthiaskrgr:rollup-7gwgvgc, r=matthiaskrgr
commit[2] 2023-03-08: Auto merge of #108312 - michaelwoerister:hash-set-not-hash-stable, r=eholk
commit[3] 2023-03-08: Auto merge of #108534 - Mark-Simulacrum:compression, r=pietroalbini
commit[4] 2023-03-08: Auto merge of #108121 - aliemjay:resolve-var-region, r=lcnr
commit[5] 2023-03-08: Auto merge of #108665 - weihanglo:update-cargo, r=weihanglo