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 fix fails: warning: failed to automatically apply fixes suggested by rustc to crate rust_bug1 #86538

Closed
chathaway-codes opened this issue Jun 22, 2021 · 3 comments
Labels
C-bug Category: This is a bug.

Comments

@chathaway-codes
Copy link
Contributor

I tried this code:

struct Player {
    hand: Vec<usize>,
}

fn main() {
    let p = Player {
        hand: vec![1, 2, 3, 4, 5],
    };
    let filter_hand = vec![5];
    let new_hand: Vec<usize> = p
        .hand
        .iter()
        .filter(|c| filter_hand.iter().find(|cc| c == cc).is_none())
        .map(|c| c.clone())
        .collect();
    println!("Hello, world!");
}

(this is a reduced and largely nonsensical version of the real issue I hit)

With the command: cargo clippy --fix -Z unstable-options --allow-dirty

I expected to see this happen: Clippy cleanup the source code without error.

Instead, this happened: I got a rather long error message, [output.txt] attached.

output.txt

Meta

rustc --version --verbose:

% rustc --version --verbose
rustc 1.55.0-nightly (ce1d5611a 2021-06-18)
binary: rustc
commit-hash: ce1d5611a28468663e275078649e7ca6eef735a8
commit-date: 2021-06-18
host: x86_64-unknown-linux-gnu
release: 1.55.0-nightly
LLVM version: 12.0.1
Backtrace

N/A; doesn't crash

@chathaway-codes chathaway-codes added the C-bug Category: This is a bug. label Jun 22, 2021
@ehuss
Copy link
Contributor

ehuss commented Jun 22, 2021

Thanks for the report! This looks like an issue with clippy where it gives a bad suggestion (the signature of find and any aren't the same). Would you mind moving this issue to the clippy tracker at https://github.com/rust-lang/rust-clippy/issues?

@chathaway-codes
Copy link
Contributor Author

Done; opened rust-lang/rust-clippy#7392

@ehuss
Copy link
Contributor

ehuss commented Jun 22, 2021

Thanks!

@ehuss ehuss closed this as completed Jun 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug.
Projects
None yet
Development

No branches or pull requests

2 participants