2023-04-20 14:37:15 +00:00
|
|
|
//@run-rustfix
|
2021-04-02 21:35:32 +00:00
|
|
|
#![allow(clippy::useless_vec, clippy::needless_borrow)]
|
2018-10-20 20:03:38 +00:00
|
|
|
#![warn(clippy::into_iter_on_ref)]
|
|
|
|
|
|
|
|
struct X;
|
|
|
|
use std::collections::*;
|
|
|
|
|
|
|
|
fn main() {
|
2018-12-09 22:26:16 +00:00
|
|
|
for _ in &[1, 2, 3] {}
|
2018-10-20 20:03:38 +00:00
|
|
|
for _ in vec![X, X] {}
|
|
|
|
for _ in &vec![X, X] {}
|
|
|
|
|
2018-12-09 22:26:16 +00:00
|
|
|
let _ = vec![1, 2, 3].into_iter();
|
2023-04-20 15:19:36 +00:00
|
|
|
let _ = (&vec![1, 2, 3]).into_iter(); //~ ERROR: equivalent to `.iter()
|
|
|
|
let _ = vec![1, 2, 3].into_boxed_slice().into_iter(); //~ ERROR: equivalent to `.iter()
|
|
|
|
let _ = std::rc::Rc::from(&[X][..]).into_iter(); //~ ERROR: equivalent to `.iter()
|
|
|
|
let _ = std::sync::Arc::from(&[X][..]).into_iter(); //~ ERROR: equivalent to `.iter()
|
2018-10-20 20:03:38 +00:00
|
|
|
|
2023-04-20 15:19:36 +00:00
|
|
|
let _ = (&&&&&&&[1, 2, 3]).into_iter(); //~ ERROR: equivalent to `.iter()
|
|
|
|
let _ = (&&&&mut &&&[1, 2, 3]).into_iter(); //~ ERROR: equivalent to `.iter()
|
|
|
|
let _ = (&mut &mut &mut [1, 2, 3]).into_iter(); //~ ERROR: equivalent to `.iter_mut()
|
2018-10-20 20:03:38 +00:00
|
|
|
|
2023-04-20 15:19:36 +00:00
|
|
|
let _ = (&Some(4)).into_iter(); //~ ERROR: equivalent to `.iter()
|
|
|
|
let _ = (&mut Some(5)).into_iter(); //~ ERROR: equivalent to `.iter_mut()
|
|
|
|
let _ = (&Ok::<_, i32>(6)).into_iter(); //~ ERROR: equivalent to `.iter()
|
|
|
|
let _ = (&mut Err::<i32, _>(7)).into_iter(); //~ ERROR: equivalent to `.iter_mut()
|
|
|
|
let _ = (&Vec::<i32>::new()).into_iter(); //~ ERROR: equivalent to `.iter()
|
|
|
|
let _ = (&mut Vec::<i32>::new()).into_iter(); //~ ERROR: equivalent to `.iter_mut()
|
|
|
|
let _ = (&BTreeMap::<i32, u64>::new()).into_iter(); //~ ERROR: equivalent to `.iter()
|
|
|
|
let _ = (&mut BTreeMap::<i32, u64>::new()).into_iter(); //~ ERROR: equivalent to `.iter_mut()
|
|
|
|
let _ = (&VecDeque::<i32>::new()).into_iter(); //~ ERROR: equivalent to `.iter()
|
|
|
|
let _ = (&mut VecDeque::<i32>::new()).into_iter(); //~ ERROR: equivalent to `.iter_mut()
|
|
|
|
let _ = (&LinkedList::<i32>::new()).into_iter(); //~ ERROR: equivalent to `.iter()
|
|
|
|
let _ = (&mut LinkedList::<i32>::new()).into_iter(); //~ ERROR: equivalent to `.iter_mut()
|
|
|
|
let _ = (&HashMap::<i32, u64>::new()).into_iter(); //~ ERROR: equivalent to `.iter()
|
|
|
|
let _ = (&mut HashMap::<i32, u64>::new()).into_iter(); //~ ERROR: equivalent to `.iter_mut()
|
2018-10-20 20:03:38 +00:00
|
|
|
|
2023-04-20 15:19:36 +00:00
|
|
|
let _ = (&BTreeSet::<i32>::new()).into_iter(); //~ ERROR: equivalent to `.iter()
|
|
|
|
let _ = (&BinaryHeap::<i32>::new()).into_iter(); //~ ERROR: equivalent to `.iter()
|
|
|
|
let _ = (&HashSet::<i32>::new()).into_iter(); //~ ERROR: equivalent to `.iter()
|
|
|
|
let _ = std::path::Path::new("12/34").into_iter(); //~ ERROR: equivalent to `.iter()
|
|
|
|
let _ = std::path::PathBuf::from("12/34").into_iter(); //~ ERROR: equivalent to `.iter()
|
2020-05-25 16:22:01 +00:00
|
|
|
|
2023-04-20 15:19:36 +00:00
|
|
|
let _ = (&[1, 2, 3]).into_iter().next(); //~ ERROR: equivalent to `.iter()
|
2018-10-20 20:03:38 +00:00
|
|
|
}
|