mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-25 08:13:41 +00:00
Also ignore continue
statements in is_unit_expr
This commit is contained in:
parent
7e9ba81297
commit
8c824e4cbc
@ -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 New Issue
Block a user