2021-08-08 09:49:13 -05:00
|
|
|
#![allow(clippy::blocks_in_if_conditions)]
|
2018-05-27 16:59:07 -05:00
|
|
|
#![allow(dead_code)]
|
|
|
|
|
2018-11-21 21:40:09 -06:00
|
|
|
/// Issue: https://github.com/rust-lang/rust-clippy/issues/2596
|
2018-05-27 16:59:07 -05:00
|
|
|
pub fn loop_on_block_condition(u: &mut isize) {
|
|
|
|
while { *u < 0 } {
|
|
|
|
*u += 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-11-21 21:40:09 -06:00
|
|
|
/// https://github.com/rust-lang/rust-clippy/issues/2584
|
2018-05-27 16:59:07 -05:00
|
|
|
fn loop_with_unsafe_condition(ptr: *const u8) {
|
|
|
|
let mut len = 0;
|
|
|
|
while unsafe { *ptr.offset(len) } != 0 {
|
|
|
|
len += 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-11-21 21:40:09 -06:00
|
|
|
/// https://github.com/rust-lang/rust-clippy/issues/2710
|
2018-05-27 16:59:07 -05:00
|
|
|
static mut RUNNING: bool = true;
|
|
|
|
fn loop_on_static_condition() {
|
|
|
|
unsafe {
|
|
|
|
while RUNNING {
|
|
|
|
RUNNING = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {}
|