mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-10 23:24:24 +00:00
Also ignore continue
statements in is_unit_expr
This commit is contained in:
parent
7e9ba81297
commit
8c824e4cbc
2 changed files with 33 additions and 3 deletions
|
@ -98,6 +98,7 @@ impl EarlyLintPass for UnitExpr {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn is_unit_expr(expr: &Expr) -> Option<Span> {
|
||||
match expr.node {
|
||||
ExprKind::Block(ref block) => if check_last_stmt_in_block(block) {
|
||||
|
@ -139,9 +140,13 @@ fn check_last_stmt_in_block(block: &Block) -> bool {
|
|||
// like `panic!()`
|
||||
match final_stmt.node {
|
||||
StmtKind::Expr(_) => false,
|
||||
StmtKind::Semi(ref expr) => match expr.node {
|
||||
ExprKind::Break(_, _) | ExprKind::Ret(_) => false,
|
||||
_ => true,
|
||||
StmtKind::Semi(ref expr) => {
|
||||
match expr.node {
|
||||
ExprKind::Break(_, _) |
|
||||
ExprKind::Continue(_) |
|
||||
ExprKind::Ret(_) => false,
|
||||
_ => true,
|
||||
}
|
||||
},
|
||||
_ => true,
|
||||
}
|
||||
|
|
|
@ -45,4 +45,29 @@ fn main() {
|
|||
0;
|
||||
},
|
||||
};
|
||||
|
||||
loop {
|
||||
let a2 = match a1 {
|
||||
Some(x) => x,
|
||||
_ => {
|
||||
break;
|
||||
},
|
||||
};
|
||||
let a2 = match a1 {
|
||||
Some(x) => x,
|
||||
_ => {
|
||||
continue;
|
||||
},
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
pub fn foo() -> i32 {
|
||||
let a2 = match None {
|
||||
Some(x) => x,
|
||||
_ => {
|
||||
return 42;
|
||||
},
|
||||
};
|
||||
55
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue