2023-07-27 08:23:04 -05:00
|
|
|
//@aux-build:proc_macros.rs
|
2019-05-12 05:10:23 -05:00
|
|
|
|
|
|
|
#![warn(clippy::empty_loop)]
|
|
|
|
|
2023-03-07 08:40:55 -06:00
|
|
|
extern crate proc_macros;
|
|
|
|
use proc_macros::{external, inline_macros};
|
2019-05-12 05:10:23 -05:00
|
|
|
|
|
|
|
fn should_trigger() {
|
|
|
|
loop {}
|
2023-09-02 07:12:05 -05:00
|
|
|
#[allow(clippy::never_loop)]
|
2019-05-12 05:10:23 -05:00
|
|
|
loop {
|
|
|
|
loop {}
|
|
|
|
}
|
|
|
|
|
2023-09-02 07:12:05 -05:00
|
|
|
#[allow(clippy::never_loop)]
|
2019-05-12 05:10:23 -05:00
|
|
|
'outer: loop {
|
|
|
|
'inner: loop {}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-03-07 08:40:55 -06:00
|
|
|
#[inline_macros]
|
2019-05-12 05:10:23 -05:00
|
|
|
fn should_not_trigger() {
|
2023-09-02 07:12:05 -05:00
|
|
|
#[allow(clippy::never_loop)]
|
2019-05-12 05:10:23 -05:00
|
|
|
loop {
|
|
|
|
panic!("This is fine")
|
|
|
|
}
|
|
|
|
let ten_millis = std::time::Duration::from_millis(10);
|
|
|
|
loop {
|
|
|
|
std::thread::sleep(ten_millis)
|
|
|
|
}
|
|
|
|
|
|
|
|
#[allow(clippy::never_loop)]
|
|
|
|
'outer: loop {
|
|
|
|
'inner: loop {
|
|
|
|
break 'inner;
|
|
|
|
}
|
|
|
|
break 'outer;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Make sure `allow` works for this lint
|
|
|
|
#[allow(clippy::empty_loop)]
|
|
|
|
loop {}
|
|
|
|
|
|
|
|
// We don't lint loops inside macros
|
2023-03-07 08:40:55 -06:00
|
|
|
inline!(loop {});
|
2019-05-12 05:10:23 -05:00
|
|
|
|
|
|
|
// We don't lint external macros
|
2023-03-07 08:40:55 -06:00
|
|
|
external!(loop {});
|
2019-05-12 05:10:23 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {}
|