2019-05-08 07:19:08 +00:00
|
|
|
fn main() {}
|
2023-07-27 11:40:22 +00:00
|
|
|
//@no-rustfix
|
2019-05-08 07:19:08 +00:00
|
|
|
fn no_panic<T>(slice: &[T]) {
|
|
|
|
let mut iter = slice.iter();
|
|
|
|
loop {
|
2023-09-02 12:12:05 +00:00
|
|
|
//~^ ERROR: this loop never actually loops
|
|
|
|
//~| ERROR: this loop could be written as a `while let` loop
|
2023-07-28 19:35:48 +00:00
|
|
|
//~| NOTE: `-D clippy::while-let-loop` implied by `-D warnings`
|
2019-05-08 07:19:08 +00:00
|
|
|
let _ = match iter.next() {
|
|
|
|
Some(ele) => ele,
|
|
|
|
None => break,
|
|
|
|
};
|
|
|
|
loop {}
|
2023-07-28 19:35:48 +00:00
|
|
|
//~^ ERROR: empty `loop {}` wastes CPU cycles
|
2019-05-08 07:19:08 +00:00
|
|
|
}
|
|
|
|
}
|