-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Start handling desugarings in author lint
- Loading branch information
1 parent
0499184
commit 19cfb84
Showing
4 changed files
with
64 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#[allow(clippy::all)] | ||
|
||
fn main() { | ||
#[clippy::author] | ||
let _ = if true { | ||
1 == 1; | ||
} else { | ||
2 == 2; | ||
}; | ||
} |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
if_chain! { | ||
if let StmtKind::Local(ref local) = stmt.node; | ||
if let Some(ref init) = local.init; | ||
if let Some((ref cond, ref then, Some(else_))) = higher::if_block(&init); | ||
if let ExprKind::Block(ref block) = else_.node; | ||
if let StmtKind::Semi(ref e, _) = block.node | ||
if let ExprKind::Binary(ref op, ref left, ref right) = e.node; | ||
if BinOpKind::Eq == op.node; | ||
if let ExprKind::Lit(ref lit) = left.node; | ||
if let LitKind::Int(2, _) = lit.node; | ||
if let ExprKind::Lit(ref lit1) = right.node; | ||
if let LitKind::Int(2, _) = lit1.node; | ||
if let ExprKind::Lit(ref lit2) = cond.node; | ||
if let LitKind::Bool(true) = lit2.node; | ||
if let ExprKind::Block(ref block1) = then.node; | ||
if let StmtKind::Semi(ref e1, _) = block1.node | ||
if let ExprKind::Binary(ref op1, ref left1, ref right1) = e1.node; | ||
if BinOpKind::Eq == op1.node; | ||
if let ExprKind::Lit(ref lit3) = left1.node; | ||
if let LitKind::Int(1, _) = lit3.node; | ||
if let ExprKind::Lit(ref lit4) = right1.node; | ||
if let LitKind::Int(1, _) = lit4.node; | ||
if let PatKind::Wild = local.pat.node; | ||
then { | ||
// report your lint here | ||
} | ||
} |