mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-12-18 00:53:31 +00:00
5379fc1b28
allow condition to be a block: by calling visit_expr of the visitor directly on the condition instead of walk_expr on the whole expression, we bypass the match to ExprWhile that calls visit_expr on the condition and visit_block on the body. This allow to re-enable visit_block in the visitor, as it won't be called on the while body allow condition to use static variables: maintain a list of static variables used, and if they are mutable
28 lines
625 B
Rust
28 lines
625 B
Rust
#![allow(dead_code)]
|
|
|
|
/// Issue: https://github.com/rust-lang-nursery/rust-clippy/issues/2596
|
|
pub fn loop_on_block_condition(u: &mut isize) {
|
|
while { *u < 0 } {
|
|
*u += 1;
|
|
}
|
|
}
|
|
|
|
/// https://github.com/rust-lang-nursery/rust-clippy/issues/2584
|
|
fn loop_with_unsafe_condition(ptr: *const u8) {
|
|
let mut len = 0;
|
|
while unsafe { *ptr.offset(len) } != 0 {
|
|
len += 1;
|
|
}
|
|
}
|
|
|
|
/// https://github.com/rust-lang-nursery/rust-clippy/issues/2710
|
|
static mut RUNNING: bool = true;
|
|
fn loop_on_static_condition() {
|
|
unsafe {
|
|
while RUNNING {
|
|
RUNNING = false;
|
|
}
|
|
}
|
|
}
|
|
|
|
fn main() {}
|