]> git.lizzy.rs Git - rust.git/blob - tests/ui/empty_loop.rs
Auto merge of #4314 - chansuke:add-negation-to-is_empty, r=flip1995
[rust.git] / tests / ui / empty_loop.rs
1 // aux-build:macro_rules.rs
2
3 #![warn(clippy::empty_loop)]
4 #![allow(clippy::unused_label)]
5
6 #[macro_use]
7 extern crate macro_rules;
8
9 fn should_trigger() {
10     loop {}
11     loop {
12         loop {}
13     }
14
15     'outer: loop {
16         'inner: loop {}
17     }
18 }
19
20 fn should_not_trigger() {
21     loop {
22         panic!("This is fine")
23     }
24     let ten_millis = std::time::Duration::from_millis(10);
25     loop {
26         std::thread::sleep(ten_millis)
27     }
28
29     #[allow(clippy::never_loop)]
30     'outer: loop {
31         'inner: loop {
32             break 'inner;
33         }
34         break 'outer;
35     }
36
37     // Make sure `allow` works for this lint
38     #[allow(clippy::empty_loop)]
39     loop {}
40
41     // We don't lint loops inside macros
42     macro_rules! foo {
43         () => {
44             loop {}
45         };
46     }
47
48     // We don't lint external macros
49     foofoo!()
50 }
51
52 fn main() {}