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

collapsible_if false positive #6593

Closed
piscisaureus opened this issue Jan 15, 2021 · 0 comments · Fixed by #6701
Closed

collapsible_if false positive #6593

piscisaureus opened this issue Jan 15, 2021 · 0 comments · Fixed by #6701
Labels
C-bug Category: Clippy is not doing the correct thing I-false-positive Issue: The lint was triggered on code it shouldn't have

Comments

@piscisaureus
Copy link

A #[cfg(unix)] attribute can make an if statement non-collapsible, but its presence is ignored by clippy.
cargo clippy --fix drops the attribute altogether.

Lint name

collapsible-if

Example

fn test() {
  if condition() {
    // ...
  } else {
    #[cfg(unix)]
    if let Some(unix_only) = resource.downcast::<UnixOnlyType>() {
      // ...
    }
  }
}

Meta

~🦕 cargo clippy -V
clippy 0.1.51 (e38fb30 2021-01-14)

~🦕 rustc -Vv
rustc 1.51.0-nightly (e38fb306b 2021-01-14)
binary: rustc
commit-hash: e38fb306b7f5e65cca34df2dab1f0db15e1defb4
commit-date: 2021-01-14
host: x86_64-unknown-linux-gnu
release: 1.51.0-nightly
LLVM version: 11.0
@piscisaureus piscisaureus added C-bug Category: Clippy is not doing the correct thing I-false-positive Issue: The lint was triggered on code it shouldn't have labels Jan 15, 2021
@bors bors closed this as completed in 9c3b43e Feb 14, 2021
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 I-false-positive Issue: The lint was triggered on code it shouldn't have
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant