2018-10-06 18:18:06 +02:00
|
|
|
// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT
|
|
|
|
// file at the top-level directory of this distribution.
|
|
|
|
//
|
|
|
|
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
|
|
|
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
|
|
|
// option. This file may not be copied, modified, or distributed
|
|
|
|
// except according to those terms.
|
|
|
|
|
2018-05-27 23:59:07 +02:00
|
|
|
#![allow(dead_code)]
|
|
|
|
|
2018-11-22 04:40:09 +01:00
|
|
|
/// Issue: https://github.com/rust-lang/rust-clippy/issues/2596
|
2018-05-27 23:59:07 +02:00
|
|
|
pub fn loop_on_block_condition(u: &mut isize) {
|
|
|
|
while { *u < 0 } {
|
|
|
|
*u += 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-11-22 04:40:09 +01:00
|
|
|
/// https://github.com/rust-lang/rust-clippy/issues/2584
|
2018-05-27 23:59:07 +02:00
|
|
|
fn loop_with_unsafe_condition(ptr: *const u8) {
|
|
|
|
let mut len = 0;
|
|
|
|
while unsafe { *ptr.offset(len) } != 0 {
|
|
|
|
len += 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-11-22 04:40:09 +01:00
|
|
|
/// https://github.com/rust-lang/rust-clippy/issues/2710
|
2018-05-27 23:59:07 +02:00
|
|
|
static mut RUNNING: bool = true;
|
|
|
|
fn loop_on_static_condition() {
|
|
|
|
unsafe {
|
|
|
|
while RUNNING {
|
|
|
|
RUNNING = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {}
|