2017-02-17 03:53:14 +00:00
|
|
|
#![feature(plugin)]
|
|
|
|
#![plugin(clippy)]
|
2017-06-01 04:22:15 +00:00
|
|
|
#![allow(single_match, unused_assignments, unused_variables)]
|
2017-02-17 03:53:14 +00:00
|
|
|
|
2017-06-01 04:22:15 +00:00
|
|
|
fn test1() {
|
|
|
|
let mut x = 0;
|
|
|
|
loop { // never_loop
|
|
|
|
x += 1;
|
|
|
|
if x == 1 {
|
|
|
|
return
|
|
|
|
}
|
2017-02-17 03:53:14 +00:00
|
|
|
break;
|
|
|
|
}
|
2017-05-31 01:44:01 +00:00
|
|
|
}
|
2017-02-17 03:53:14 +00:00
|
|
|
|
2017-06-01 04:22:15 +00:00
|
|
|
fn test2() {
|
|
|
|
let mut x = 0;
|
2017-02-17 03:53:14 +00:00
|
|
|
loop {
|
2017-06-01 04:22:15 +00:00
|
|
|
x += 1;
|
2017-02-17 03:53:14 +00:00
|
|
|
if x == 1 {
|
2017-05-31 01:44:01 +00:00
|
|
|
break
|
2017-02-17 03:53:14 +00:00
|
|
|
}
|
|
|
|
}
|
2017-05-31 01:44:01 +00:00
|
|
|
}
|
2017-02-17 03:53:14 +00:00
|
|
|
|
2017-06-01 04:22:15 +00:00
|
|
|
fn test3() {
|
|
|
|
let mut x = 0;
|
|
|
|
loop { // never loops
|
|
|
|
x += 1;
|
2017-05-31 01:44:01 +00:00
|
|
|
break
|
2017-02-17 03:53:14 +00:00
|
|
|
}
|
2017-05-31 01:44:01 +00:00
|
|
|
}
|
2017-02-17 03:53:14 +00:00
|
|
|
|
2017-06-01 04:22:15 +00:00
|
|
|
fn test4() {
|
|
|
|
let mut x = 1;
|
2017-02-17 03:53:14 +00:00
|
|
|
loop {
|
2017-06-01 04:22:15 +00:00
|
|
|
x += 1;
|
|
|
|
match x {
|
|
|
|
5 => return,
|
|
|
|
_ => (),
|
2017-02-17 03:53:14 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2017-05-31 01:44:01 +00:00
|
|
|
|
2017-06-01 04:22:15 +00:00
|
|
|
fn test5() {
|
|
|
|
let i = 0;
|
|
|
|
loop { // never loops
|
|
|
|
while i == 0 { // never loops
|
|
|
|
break
|
|
|
|
}
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn test6() {
|
|
|
|
let mut x = 0;
|
|
|
|
'outer: loop { // never loops
|
|
|
|
x += 1;
|
|
|
|
loop { // never loops
|
|
|
|
if x == 5 { break }
|
|
|
|
continue 'outer
|
|
|
|
}
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn test7() {
|
|
|
|
let mut x = 0;
|
2017-05-31 01:44:01 +00:00
|
|
|
loop {
|
2017-06-01 04:22:15 +00:00
|
|
|
x += 1;
|
2017-05-31 01:44:01 +00:00
|
|
|
match x {
|
2017-06-01 04:22:15 +00:00
|
|
|
1 => continue,
|
2017-05-31 01:44:01 +00:00
|
|
|
_ => (),
|
|
|
|
}
|
2017-06-01 04:22:15 +00:00
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn test8() {
|
|
|
|
let mut x = 0;
|
|
|
|
loop {
|
|
|
|
x += 1;
|
|
|
|
match x {
|
|
|
|
5 => return,
|
|
|
|
_ => continue,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn test9() {
|
|
|
|
let x = Some(1);
|
|
|
|
while let Some(y) = x { // never loops
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn test10() {
|
|
|
|
for x in 0..10 { // never loops
|
|
|
|
match x {
|
|
|
|
1 => break,
|
|
|
|
_ => return,
|
|
|
|
}
|
2017-05-31 01:44:01 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-07-05 01:56:05 +00:00
|
|
|
fn test11<F: FnMut() -> i32>(mut f: F) {
|
|
|
|
loop {
|
|
|
|
return match f() {
|
|
|
|
1 => continue,
|
|
|
|
_ => (),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-05-31 01:44:01 +00:00
|
|
|
fn main() {
|
2017-06-01 04:22:15 +00:00
|
|
|
test1();
|
|
|
|
test2();
|
|
|
|
test3();
|
|
|
|
test4();
|
|
|
|
test5();
|
|
|
|
test6();
|
|
|
|
test7();
|
|
|
|
test8();
|
|
|
|
test9();
|
|
|
|
test10();
|
2017-07-05 01:56:05 +00:00
|
|
|
test11(|| 0);
|
2017-05-31 01:44:01 +00:00
|
|
|
}
|
2017-06-01 04:22:15 +00:00
|
|
|
|