File tree Expand file tree Collapse file tree 3 files changed +83
-0
lines changed Expand file tree Collapse file tree 3 files changed +83
-0
lines changed Original file line number Diff line number Diff line change 1+ #![ allow( dead_code) ]
2+
3+ /// Used to test that certain lints don't trigger in imported external macros
4+ #[ macro_export]
5+ macro_rules! foofoo {
6+ ( ) => {
7+ loop { }
8+ } ;
9+ }
Original file line number Diff line number Diff line change 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 ( ) { }
Original file line number Diff line number Diff line change 1+ error: empty `loop {}` detected. You may want to either use `panic!()` or add `std::thread::sleep(..);` to the loop body.
2+ --> $DIR/empty_loop.rs:10:5
3+ |
4+ LL | loop {}
5+ | ^^^^^^^
6+ |
7+ = note: `-D clippy::empty-loop` implied by `-D warnings`
8+
9+ error: empty `loop {}` detected. You may want to either use `panic!()` or add `std::thread::sleep(..);` to the loop body.
10+ --> $DIR/empty_loop.rs:12:9
11+ |
12+ LL | loop {}
13+ | ^^^^^^^
14+
15+ error: empty `loop {}` detected. You may want to either use `panic!()` or add `std::thread::sleep(..);` to the loop body.
16+ --> $DIR/empty_loop.rs:16:9
17+ |
18+ LL | 'inner: loop {}
19+ | ^^^^^^^^^^^^^^^
20+
21+ error: aborting due to 3 previous errors
22+
You can’t perform that action at this time.
0 commit comments