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

Clippy hangs forever for long "if" logical condition #11257

Closed
charles-wangkai opened this issue Jul 30, 2023 · 2 comments · Fixed by #13209
Closed

Clippy hangs forever for long "if" logical condition #11257

charles-wangkai opened this issue Jul 30, 2023 · 2 comments · Fixed by #13209
Labels
C-bug Category: Clippy is not doing the correct thing

Comments

@charles-wangkai
Copy link

Summary

> cargo clippy -V
clippy 0.1.71 (8ede3aae 2023-07-12)

Clippy hangs forever for the following code with a long "if" logical condition.

Reproducer

I tried this code:

fn main() {}

fn search(visited: &mut [[bool; 7]], r: usize, c: usize) -> i32 {
    if (r != 0
        && !visited[r - 1][c]
        && r != 6
        && !visited[r + 1][c]
        && (c == 0 || visited[r][c - 1])
        && (c == 6 || visited[r][c + 1]))
        || (c != 0
            && !visited[r][c - 1]
            && c != 6
            && !visited[r][c + 1]
            && (r == 0 || visited[r - 1][c])
            && (r == 6 || visited[r + 1][c]))
    {
        return 0;
    }

    todo!()
}

I expected to see this happen:
Finish quickly.

Instead, this happened:
Hangs forever.

Version

rustc 1.71.0 (8ede3aae2 2023-07-12)
binary: rustc
commit-hash: 8ede3aae28fe6e4d52b38157d7bfe0d3bceef225
commit-date: 2023-07-12
host: x86_64-apple-darwin
release: 1.71.0
LLVM version: 16.0.5

Additional Labels

No response

@charles-wangkai charles-wangkai added the C-bug Category: Clippy is not doing the correct thing label Jul 30, 2023
@y21
Copy link
Member

y21 commented Jul 30, 2023

It gets stuck here

for simple in Bool::Not(Box::new(expr)).simplify() {

Seems to be taking quite a while to simplify expressions. There's a comment a few lines above saying that it has exponentially slow behavior and it links to #825, which looks quite similar to the issue here.

@blyxyas
Copy link
Member

blyxyas commented May 24, 2024

This is a known issue, with an issue filed oli-obk/quine-mc_cluskey#2. I would fix it if I had access to the paper, but it's behind a paywall.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: Clippy is not doing the correct thing
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants