about summary refs log tree commit diff
path: root/src/test/codegen/src-hash-algorithm
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2020-12-13 21:28:38 +0000
committerbors <bors@rust-lang.org>2020-12-13 21:28:38 +0000
commitd9241640e8ffe4bca3433204cc04d7e67a7c4171 (patch)
tree718c30d2c73e414cb1bbba48f6d6495443914dfa /src/test/codegen/src-hash-algorithm
parenta642b42a46e1ae7e82945b7cb88c75d4c06529bf (diff)
parenta37af06fea574f3d9f4d3cca58a70cd545523486 (diff)
downloadrust-d9241640e8ffe4bca3433204cc04d7e67a7c4171.tar.gz
rust-d9241640e8ffe4bca3433204cc04d7e67a7c4171.zip
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
Diffstat (limited to 'src/test/codegen/src-hash-algorithm')
0 files changed, 0 insertions, 0 deletions