Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chaining filter calls on iterators leads to exponentially slower compile times #33245

Closed
jabagawee opened this issue Apr 27, 2016 · 1 comment

Comments

@jabagawee
Copy link

Apologies if this is a known problem already. I was working through a fairly simple Project Euler problem to learn some Rust and I think I found an issue (with possibly the type checker?).

I tried this code:

fn main() {
    let mut iterator = (1..)
        .filter(|x| x % 1 == 0)
        .filter(|x| x % 2 == 0)
        .filter(|x| x % 3 == 0)
        .filter(|x| x % 4 == 0)
        .filter(|x| x % 5 == 0)
        .filter(|x| x % 6 == 0)
        // .filter(|x| x % 7 == 0)
        // .filter(|x| x % 8 == 0)
        // .filter(|x| x % 9 == 0)
        // .filter(|x| x % 10 == 0);
    let answer = iterator.next().unwrap();
    println!("{}", answer);
}

I expected to see this happen: Compiling this should be pretty fast.

Instead, this happened: Exponential slowdown as I uncomment each filter line one by one

Meta

rustc --version --verbose:

rustc 1.10.0-nightly (bd938166d 2016-04-25)
binary: rustc
commit-hash: bd938166d6dabc689777555d5046dce893555eb7
commit-date: 2016-04-25
host: x86_64-apple-darwin
release: 1.10.0-nightly

Backtrace: No backtrace

@nagisa
Copy link
Member

nagisa commented Apr 27, 2016

We already know about this issue¹. Thanks for the report!

¹: See #22204

@nagisa nagisa closed this as completed Apr 27, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants