// run-rustfix
-
#![allow(dead_code, unused)]
+#![allow(clippy::uninlined_format_args)]
use std::collections::*;
clippy::explicit_iter_loop,
clippy::explicit_into_iter_loop,
clippy::iter_next_loop,
- clippy::reverse_range_loop,
clippy::for_kv_map
)]
#[allow(
clippy::linkedlist,
- clippy::shadow_unrelated,
clippy::unnecessary_mut_passed,
- clippy::similar_names
+ clippy::similar_names,
+ clippy::needless_borrow
)]
-#[allow(clippy::many_single_char_names, unused_variables)]
+#[allow(unused_variables)]
fn main() {
- const MAX_LEN: usize = 42;
let mut vec = vec![1, 2, 3, 4];
- for i in 10..0 {
- println!("{}", i);
- }
-
- for i in 10..=0 {
- println!("{}", i);
- }
-
- for i in MAX_LEN..0 {
- println!("{}", i);
- }
-
- for i in 5..=5 {
- // not an error, this is the range with only one element “5”
- println!("{}", i);
- }
-
- for i in 0..10 {
- // not an error, the start index is less than the end index
- println!("{}", i);
- }
-
- for i in -10..0 {
- // not an error
- println!("{}", i);
- }
-
- for i in (10..0).map(|x| x * 2) {
- // not an error, it can't be known what arbitrary methods do to a range
- println!("{}", i);
- }
-
- // testing that the empty range lint folds constants
- for i in 10..5 + 4 {
- println!("{}", i);
- }
-
- for i in (5 + 2)..(3 - 1) {
- println!("{}", i);
- }
-
- for i in (2 * 2)..(2 * 3) {
- // no error, 4..6 is fine
- println!("{}", i);
- }
-
- let x = 42;
- for i in x..10 {
- // no error, not constant-foldable
- println!("{}", i);
- }
-
// See #601
for i in 0..10 {
// no error, id_col does not exist outside the loop
for _ in rr.into_iter() {}
}
}
+
+// explicit_into_iter_loop
+#[warn(clippy::explicit_into_iter_loop)]
+mod issue_6900 {
+ struct S;
+ impl S {
+ #[allow(clippy::should_implement_trait)]
+ pub fn into_iter<T>(self) -> I<T> {
+ unimplemented!()
+ }
+ }
+
+ struct I<T>(T);
+ impl<T> Iterator for I<T> {
+ type Item = T;
+ fn next(&mut self) -> Option<Self::Item> {
+ unimplemented!()
+ }
+ }
+
+ fn f() {
+ for _ in S.into_iter::<u32>() {
+ unimplemented!()
+ }
+ }
+}