mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-15 01:17:16 +00:00
42f03539ca
I found this because we only had two test cases in total for this lint. It turns out the functionality is fully covered by rustc these days. [Playground Examples](https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=eb8ee6db389c77180c9fb152d3c608f4) changelog: Deprecate `unused_collect` lint. This is fully covered by rustc's `#[must_use]` on `collect` cc #2846
109 lines
3.2 KiB
Text
109 lines
3.2 KiB
Text
error: infinite iteration detected
|
|
--> $DIR/infinite_iter.rs:10:5
|
|
|
|
|
LL | repeat(0_u8).collect::<Vec<_>>(); // infinite iter
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
|
|
|
note: lint level defined here
|
|
--> $DIR/infinite_iter.rs:8:8
|
|
|
|
|
LL | #[deny(clippy::infinite_iter)]
|
|
| ^^^^^^^^^^^^^^^^^^^^^
|
|
|
|
error: infinite iteration detected
|
|
--> $DIR/infinite_iter.rs:11:5
|
|
|
|
|
LL | (0..8_u32).take_while(square_is_lower_64).cycle().count(); // infinite iter
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
|
|
error: infinite iteration detected
|
|
--> $DIR/infinite_iter.rs:12:5
|
|
|
|
|
LL | (0..8_u64).chain(0..).max(); // infinite iter
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
|
|
error: infinite iteration detected
|
|
--> $DIR/infinite_iter.rs:17:5
|
|
|
|
|
LL | / (0..8_u32)
|
|
LL | | .rev()
|
|
LL | | .cycle()
|
|
LL | | .map(|x| x + 1_u32)
|
|
LL | | .for_each(|x| println!("{}", x)); // infinite iter
|
|
| |________________________________________^
|
|
|
|
error: infinite iteration detected
|
|
--> $DIR/infinite_iter.rs:23:5
|
|
|
|
|
LL | (0_usize..).flat_map(|x| 0..x).product::<usize>(); // infinite iter
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
|
|
error: infinite iteration detected
|
|
--> $DIR/infinite_iter.rs:24:5
|
|
|
|
|
LL | (0_u64..).filter(|x| x % 2 == 0).last(); // infinite iter
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
|
|
error: possible infinite iteration detected
|
|
--> $DIR/infinite_iter.rs:31:5
|
|
|
|
|
LL | (0..).zip((0..).take_while(square_is_lower_64)).count(); // maybe infinite iter
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
|
|
|
note: lint level defined here
|
|
--> $DIR/infinite_iter.rs:29:8
|
|
|
|
|
LL | #[deny(clippy::maybe_infinite_iter)]
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
|
|
error: possible infinite iteration detected
|
|
--> $DIR/infinite_iter.rs:32:5
|
|
|
|
|
LL | repeat(42).take_while(|x| *x == 42).chain(0..42).max(); // maybe infinite iter
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
|
|
error: possible infinite iteration detected
|
|
--> $DIR/infinite_iter.rs:33:5
|
|
|
|
|
LL | / (1..)
|
|
LL | | .scan(0, |state, x| {
|
|
LL | | *state += x;
|
|
LL | | Some(*state)
|
|
LL | | })
|
|
LL | | .min(); // maybe infinite iter
|
|
| |______________^
|
|
|
|
error: possible infinite iteration detected
|
|
--> $DIR/infinite_iter.rs:39:5
|
|
|
|
|
LL | (0..).find(|x| *x == 24); // maybe infinite iter
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^
|
|
|
|
error: possible infinite iteration detected
|
|
--> $DIR/infinite_iter.rs:40:5
|
|
|
|
|
LL | (0..).position(|x| x == 24); // maybe infinite iter
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
|
|
error: possible infinite iteration detected
|
|
--> $DIR/infinite_iter.rs:41:5
|
|
|
|
|
LL | (0..).any(|x| x == 24); // maybe infinite iter
|
|
| ^^^^^^^^^^^^^^^^^^^^^^
|
|
|
|
error: possible infinite iteration detected
|
|
--> $DIR/infinite_iter.rs:42:5
|
|
|
|
|
LL | (0..).all(|x| x == 24); // maybe infinite iter
|
|
| ^^^^^^^^^^^^^^^^^^^^^^
|
|
|
|
error: infinite iteration detected
|
|
--> $DIR/infinite_iter.rs:65:31
|
|
|
|
|
LL | let _: HashSet<i32> = (0..).collect(); // Infinite iter
|
|
| ^^^^^^^^^^^^^^^
|
|
|
|
|
= note: `#[deny(clippy::infinite_iter)]` on by default
|
|
|
|
error: aborting due to 14 previous errors
|
|
|