Skip to content

Apparent infinite loop when passing infinitely recursive type using Iterator::filter #91498

@shepmaster

Description

@shepmaster

I tried this code:

fn recur(lines: impl Iterator) {
    recur(lines.filter(|_| true))
}

fn main() {
    recur([0u8].into_iter());
}

I expected the compiler would provide an error message, akin to reached the recursion limit while instantiating.

Instead, the compiler appears to hang indefinitely — I killed the process after a while.

Meta

% rustc +stable --version --verbose
rustc 1.57.0 (f1edd0429 2021-11-29)
binary: rustc
commit-hash: f1edd0429582dd29cccacaf50fd134b05593bd9c
commit-date: 2021-11-29
host: aarch64-apple-darwin
release: 1.57.0
LLVM version: 13.0.0

% rustc +nightly --version --verbose
rustc 1.59.0-nightly (acbe4443c 2021-12-02)
binary: rustc
commit-hash: acbe4443cc4c9695c0b74a7b64b60333c990a400
commit-date: 2021-12-02
host: aarch64-apple-darwin
release: 1.59.0-nightly
LLVM version: 13.0.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-type-systemArea: Type systemC-bugCategory: This is a bug.I-hangIssue: The compiler never terminates, due to infinite loops, deadlock, livelock, etc.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.T-typesRelevant to the types team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions