rust-clippy/tests/ui/empty_loop_no_std.rs

29 lines
613 B
Rust
Raw Normal View History

//@compile-flags: -Clink-arg=-nostartfiles
2024-08-17 19:38:10 +00:00
//@ignore-target: apple
2020-01-24 10:50:03 +00:00
#![warn(clippy::empty_loop)]
2021-04-03 17:20:18 +00:00
#![feature(lang_items, start, libc)]
2020-01-24 10:50:03 +00:00
#![no_std]
use core::panic::PanicInfo;
#[start]
fn main(argc: isize, argv: *const *const u8) -> isize {
// This should trigger the lint
2020-01-24 10:50:03 +00:00
loop {}
//~^ ERROR: empty `loop {}` wastes CPU cycles
2020-01-24 10:50:03 +00:00
}
#[panic_handler]
fn panic(_info: &PanicInfo) -> ! {
// This should NOT trigger the lint
2020-01-24 10:50:03 +00:00
loop {}
}
#[lang = "eh_personality"]
extern "C" fn eh_personality() {
// This should also trigger the lint
loop {}
//~^ ERROR: empty `loop {}` wastes CPU cycles
}