rust/clippy_lints
bors d9241640e8 Auto merge of #6435 - xFrednet:5552-false-positive-match-single-binding, r=ebroto
Fixing a false positive for the `match_single_binding` lint #5552

This is a fix for a false positive in the `match_single_binding` lint when using `#[cfg()]` on a branch. It is sadly a bit hacky but maybe the best solution as rust removes the other branch from the AST before we can even validate it. This fix looks at the code snippet itself and returns if it includes another thick arrow `=>` besides the one matching arm we found. This can again cause false negatives if someone has the following code:
```rust
match x {
    // => <-- Causes a false negative
    _ => 1,
}
```

I thought about making the code more complex and maybe validating against other things like the `#[cfg()]` macro but I believe that this is the best solution. This has basically switched the issue from a false positive to a false negative in a very specific case.

I'm happy to make some changes if you have any suggestions 🙃.

---
Fixes #5552

changelog: Fixed a false positive in the `match_single_binding` lint with `#[cfg()]` macro
2020-12-13 21:28:38 +00:00
..
src Auto merge of #6435 - xFrednet:5552-false-positive-match-single-binding, r=ebroto 2020-12-13 21:28:38 +00:00
Cargo.toml Merge commit 'c1664c50b27a51f7a78c93ba65558e7c33eabee6' into clippyup 2020-12-06 15:01:03 +01:00
README.md

This crate contains Clippy lints. For the main crate, check GitHub.