author: check block.expr: None

This commit is contained in:
Cameron Steffen 2021-07-25 16:35:35 -05:00
parent afe5962d38
commit d3492a0894
4 changed files with 7 additions and 0 deletions

View file

@ -554,6 +554,8 @@ impl<'tcx> Visitor<'tcx> for PrintVisitor {
self.current = self.next("trailing_expr");
println!(" if let Some({}) = &{}.expr;", self.current, block_name);
self.visit_expr(expr);
} else {
println!(" if {}.expr.is_none();", block_name);
}
}

View file

@ -11,6 +11,7 @@ if_chain! {
if let ExprKind::Unary(UnOp::Neg, ref inner) = e.kind;
if let ExprKind::Path(ref path) = inner.kind;
if match_qpath(path, &["x"]);
if block.expr.is_none();
then {
// report your lint here
}

View file

@ -54,6 +54,8 @@ if_chain! {
if match_qpath(path9, &["y"]);
if let PatKind::Binding(BindingAnnotation::Unannotated, _, name2, None) = local2.pat.kind;
if name2.as_str() == "z";
if block.expr.is_none();
if body.expr.is_none();
if let PatKind::Binding(BindingAnnotation::Mutable, _, name3, None) = arms[0].pat.kind;
if name3.as_str() == "iter";
then {

View file

@ -11,6 +11,7 @@ if_chain! {
if let LitKind::Int(2, _) = lit.node;
if let ExprKind::Lit(ref lit1) = right.kind;
if let LitKind::Int(2, _) = lit1.node;
if block.expr.is_none();
if let ExprKind::Lit(ref lit2) = cond.kind;
if let LitKind::Bool(true) = lit2.node;
if let ExprKind::Block(ref block1) = then.kind;
@ -22,6 +23,7 @@ if_chain! {
if let LitKind::Int(1, _) = lit3.node;
if let ExprKind::Lit(ref lit4) = right1.kind;
if let LitKind::Int(1, _) = lit4.node;
if block1.expr.is_none();
if let PatKind::Wild = local.pat.kind;
then {
// report your lint here