summaryrefslogtreecommitdiffstats
path: root/src/tools/clippy/tests/ui/crashes/issues_loop_mut_cond.rs
blob: bb238c81ebc05376a3a60ffe49442101d5202b00 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#![allow(dead_code)]

/// Issue: https://github.com/rust-lang/rust-clippy/issues/2596
pub fn loop_on_block_condition(u: &mut isize) {
    while { *u < 0 } {
        *u += 1;
    }
}

/// https://github.com/rust-lang/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/rust-clippy/issues/2710
static mut RUNNING: bool = true;
fn loop_on_static_condition() {
    unsafe {
        while RUNNING {
            RUNNING = false;
        }
    }
}

fn main() {}