2018-12-05 07:39:09 -06:00
|
|
|
#![warn(clippy::implicit_return)]
|
2018-12-04 18:59:09 -06:00
|
|
|
|
|
|
|
fn test_end_of_fn() -> bool {
|
|
|
|
if true {
|
|
|
|
// no error!
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
true
|
|
|
|
}
|
|
|
|
|
|
|
|
#[allow(clippy::needless_bool)]
|
|
|
|
fn test_if_block() -> bool {
|
|
|
|
if true {
|
|
|
|
true
|
|
|
|
} else {
|
|
|
|
false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#[allow(clippy::match_bool)]
|
2018-12-10 17:59:59 -06:00
|
|
|
#[rustfmt::skip]
|
2018-12-04 18:59:09 -06:00
|
|
|
fn test_match(x: bool) -> bool {
|
|
|
|
match x {
|
|
|
|
true => false,
|
2018-12-10 17:59:59 -06:00
|
|
|
false => { true },
|
2018-12-04 18:59:09 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-12-05 07:39:09 -06:00
|
|
|
#[allow(clippy::never_loop)]
|
|
|
|
fn test_loop() -> bool {
|
|
|
|
loop {
|
|
|
|
break true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-12-16 08:42:02 -06:00
|
|
|
#[allow(clippy::never_loop)]
|
|
|
|
fn test_loop_with_block() -> bool {
|
|
|
|
loop {
|
|
|
|
{
|
|
|
|
break true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#[allow(clippy::never_loop)]
|
|
|
|
fn test_loop_with_nests() -> bool {
|
|
|
|
loop {
|
|
|
|
if true {
|
2018-12-16 15:20:05 -06:00
|
|
|
break true;
|
2018-12-27 09:17:45 -06:00
|
|
|
} else {
|
2018-12-16 15:20:05 -06:00
|
|
|
let _ = true;
|
2018-12-16 08:42:02 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-12-04 18:59:09 -06:00
|
|
|
fn test_closure() {
|
2018-12-10 17:59:59 -06:00
|
|
|
#[rustfmt::skip]
|
|
|
|
let _ = || { true };
|
2018-12-04 18:59:09 -06:00
|
|
|
let _ = || true;
|
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
let _ = test_end_of_fn();
|
|
|
|
let _ = test_if_block();
|
|
|
|
let _ = test_match(true);
|
2018-12-05 07:39:09 -06:00
|
|
|
let _ = test_loop();
|
2018-12-16 08:42:02 -06:00
|
|
|
let _ = test_loop_with_block();
|
|
|
|
let _ = test_loop_with_nests();
|
2018-12-04 18:59:09 -06:00
|
|
|
test_closure();
|
|
|
|
}
|