Merge pull request #2052 from topecongiro/issue-1990
Add ExprLoop to contains_continue_expr()
This commit is contained in:
commit
f64bae4ae3
4 changed files with 21 additions and 18 deletions
6
Cargo.lock
generated
6
Cargo.lock
generated
|
@ -1,6 +1,6 @@
|
|||
[root]
|
||||
name = "clippy_lints"
|
||||
version = "0.0.159"
|
||||
version = "0.0.161"
|
||||
dependencies = [
|
||||
"itertools 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"lazy_static 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
@ -73,11 +73,11 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||
|
||||
[[package]]
|
||||
name = "clippy"
|
||||
version = "0.0.159"
|
||||
version = "0.0.161"
|
||||
dependencies = [
|
||||
"cargo_metadata 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"clippy-mini-macro-test 0.1.0",
|
||||
"clippy_lints 0.0.159",
|
||||
"clippy_lints 0.0.161",
|
||||
"compiletest_rs 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"duct 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"lazy_static 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
|
|
@ -526,7 +526,7 @@ fn contains_continue_expr(expr: &Expr, dest: &NodeId) -> bool {
|
|||
ExprMatch(ref e, ref arms, _) => {
|
||||
contains_continue_expr(e, dest) || arms.iter().any(|a| contains_continue_expr(&a.body, dest))
|
||||
},
|
||||
ExprBlock(ref block) => contains_continue_block(block, dest),
|
||||
ExprBlock(ref block) | ExprLoop(ref block, ..) => contains_continue_block(block, dest),
|
||||
ExprStruct(_, _, ref base) => base.as_ref()
|
||||
.map_or(false, |e| contains_continue_expr(e, dest)),
|
||||
ExprAgain(d) => d.target_id.opt_id().map_or(false, |id| id == *dest),
|
||||
|
|
|
@ -54,7 +54,7 @@ fn test5() {
|
|||
|
||||
fn test6() {
|
||||
let mut x = 0;
|
||||
'outer: loop { // never loops
|
||||
'outer: loop {
|
||||
x += 1;
|
||||
loop { // never loops
|
||||
if x == 5 { break }
|
||||
|
@ -112,6 +112,20 @@ fn test11<F: FnMut() -> i32>(mut f: F) {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn test12(a: bool, b: bool) {
|
||||
'label: loop {
|
||||
loop {
|
||||
if a {
|
||||
continue 'label;
|
||||
}
|
||||
if b {
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
test1();
|
||||
test2();
|
||||
|
@ -124,5 +138,6 @@ fn main() {
|
|||
test9();
|
||||
test10();
|
||||
test11(|| 0);
|
||||
test12(true, false);
|
||||
}
|
||||
|
||||
|
|
|
@ -40,18 +40,6 @@ error: this loop never actually loops
|
|||
50 | | }
|
||||
| |_________^
|
||||
|
||||
error: this loop never actually loops
|
||||
--> $DIR/never_loop.rs:57:5
|
||||
|
|
||||
57 | / 'outer: loop { // never loops
|
||||
58 | | x += 1;
|
||||
59 | | loop { // never loops
|
||||
60 | | if x == 5 { break }
|
||||
... |
|
||||
63 | | return
|
||||
64 | | }
|
||||
| |__^
|
||||
|
||||
error: this loop never actually loops
|
||||
--> $DIR/never_loop.rs:59:3
|
||||
|
|
||||
|
@ -80,5 +68,5 @@ error: this loop never actually loops
|
|||
103 | | }
|
||||
| |_____^
|
||||
|
||||
error: aborting due to 8 previous errors
|
||||
error: aborting due to 7 previous errors
|
||||
|
||||
|
|
Loading…
Reference in a new issue