- 
                Notifications
    You must be signed in to change notification settings 
- Fork 1.8k
Closed
Labels
C-bugCategory: Clippy is not doing the correct thingCategory: Clippy is not doing the correct thingI-false-positiveIssue: The lint was triggered on code it shouldn't haveIssue: The lint was triggered on code it shouldn't have
Description
Summary
empty_loop triggers on function prototypes in core
Lint Name
empty_loop
Reproducer
I tried this code:
#![feature(intrinsics)]
#![feature(rustc_attrs)]
#[rustc_intrinsic]
#[rustc_nounwind]
/// # Safety
pub const unsafe fn simd_insert<T, U>(x: T, idx: u32, val: U) -> T;I saw this happen:
warning: the feature `intrinsics` is internal to the compiler or standard library
 --> src/lib.rs:1:12
  |
1 | #![feature(intrinsics)]
  |            ^^^^^^^^^^
  |
  = note: using it is strongly discouraged
  = note: `#[warn(internal_features)]` on by default
warning: the feature `rustc_attrs` is internal to the compiler or standard library
 --> src/lib.rs:2:12
  |
2 | #![feature(rustc_attrs)]
  |            ^^^^^^^^^^^
  |
  = note: using it is strongly discouraged
warning: empty `loop {}` wastes CPU cycles
 --> src/lib.rs:6:1
  |
6 | pub const unsafe fn simd_insert<T, U>(x: T, idx: u32, val: U) -> T;
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  |
  = help: you should either use `panic!()` or add `std::thread::sleep(..);` to the loop body
  = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#empty_loop
  = note: `#[warn(clippy::empty_loop)]` on by default
I expected to see this happen:
warning: the feature `intrinsics` is internal to the compiler or standard library
 --> src/lib.rs:1:12
  |
1 | #![feature(intrinsics)]
  |            ^^^^^^^^^^
  |
  = note: using it is strongly discouraged
  = note: `#[warn(internal_features)]` on by default
warning: the feature `rustc_attrs` is internal to the compiler or standard library
 --> src/lib.rs:2:12
  |
2 | #![feature(rustc_attrs)]
  |            ^^^^^^^^^^^
  |
  = note: using it is strongly discouraged
that is, no empty loop warning
Version
Today's nightly.
Additional Labels
No response
Metadata
Metadata
Assignees
Labels
C-bugCategory: Clippy is not doing the correct thingCategory: Clippy is not doing the correct thingI-false-positiveIssue: The lint was triggered on code it shouldn't haveIssue: The lint was triggered on code it shouldn't have