mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-15 01:17:16 +00:00
do not trigger MATCH_LIKE_MATCHES_MACRO lint with attrs
- it can't be solved completely for attrs evaluated into `false` - change applicability to MaybeIncorrect and mention it in docs
This commit is contained in:
parent
7a73a25622
commit
e266708c42
1 changed files with 7 additions and 3 deletions
|
@ -459,7 +459,8 @@ declare_clippy_lint! {
|
|||
///
|
||||
/// **Why is this bad?** Readability and needless complexity.
|
||||
///
|
||||
/// **Known problems:** None
|
||||
/// **Known problems:** It can be FP triggered, when some arms have `cfg`
|
||||
/// attributes, which evaluate into `false`.
|
||||
///
|
||||
/// **Example:**
|
||||
/// ```rust
|
||||
|
@ -1167,13 +1168,16 @@ fn find_matches_sugg(cx: &LateContext<'_>, ex: &Expr<'_>, arms: &[Arm<'_>], expr
|
|||
if b0 != b1;
|
||||
let if_guard = &b0_arms[0].guard;
|
||||
if if_guard.is_none() || b0_arms.len() == 1;
|
||||
if b0_arms[0].attrs.is_empty();
|
||||
if b0_arms[1..].iter()
|
||||
.all(|arm| {
|
||||
find_bool_lit(&arm.body.kind, desugared).map_or(false, |b| b == b0) &&
|
||||
arm.guard.is_none()
|
||||
arm.guard.is_none() && arm.attrs.is_empty()
|
||||
});
|
||||
then {
|
||||
let mut applicability = Applicability::MachineApplicable;
|
||||
// The suggestion may be incorrect, because some arms can have `cfg` attributes
|
||||
// evaluated into `false` and so such arms will be stripped before.
|
||||
let mut applicability = Applicability::MaybeIncorrect;
|
||||
let pat = {
|
||||
use itertools::Itertools as _;
|
||||
b0_arms.iter()
|
||||
|
|
Loading…
Reference in a new issue