mirror of
https://github.com/rust-lang/rust.git
synced 2024-12-23 22:14:15 +00:00
d9241640e8
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 |
||
---|---|---|
.. | ||
src | ||
Cargo.toml | ||
README.md |