2021-04-08 10:50:13 -05:00
|
|
|
#![allow(clippy::useless_vec, clippy::needless_borrow)]
|
2019-01-13 05:52:51 -06:00
|
|
|
#![warn(clippy::into_iter_on_ref)]
|
|
|
|
|
|
|
|
struct X;
|
|
|
|
use std::collections::*;
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
for _ in &[1, 2, 3] {}
|
|
|
|
for _ in vec![X, X] {}
|
|
|
|
for _ in &vec![X, X] {}
|
|
|
|
|
|
|
|
let _ = vec![1, 2, 3].into_iter();
|
2023-07-02 07:35:19 -05:00
|
|
|
let _ = (&vec![1, 2, 3]).iter(); //~ ERROR: equivalent to `.iter()
|
|
|
|
let _ = std::rc::Rc::from(&[X][..]).iter(); //~ ERROR: equivalent to `.iter()
|
|
|
|
let _ = std::sync::Arc::from(&[X][..]).iter(); //~ ERROR: equivalent to `.iter()
|
2019-01-13 05:52:51 -06:00
|
|
|
|
2023-07-02 07:35:19 -05:00
|
|
|
let _ = (&&&&&&&[1, 2, 3]).iter(); //~ ERROR: equivalent to `.iter()
|
|
|
|
let _ = (&&&&mut &&&[1, 2, 3]).iter(); //~ ERROR: equivalent to `.iter()
|
|
|
|
let _ = (&mut &mut &mut [1, 2, 3]).iter_mut(); //~ ERROR: equivalent to `.iter_mut()
|
2019-01-13 05:52:51 -06:00
|
|
|
|
2023-07-02 07:35:19 -05:00
|
|
|
let _ = (&Some(4)).iter(); //~ ERROR: equivalent to `.iter()
|
|
|
|
let _ = (&mut Some(5)).iter_mut(); //~ ERROR: equivalent to `.iter_mut()
|
|
|
|
let _ = (&Ok::<_, i32>(6)).iter(); //~ ERROR: equivalent to `.iter()
|
|
|
|
let _ = (&mut Err::<i32, _>(7)).iter_mut(); //~ ERROR: equivalent to `.iter_mut()
|
|
|
|
let _ = (&Vec::<i32>::new()).iter(); //~ ERROR: equivalent to `.iter()
|
|
|
|
let _ = (&mut Vec::<i32>::new()).iter_mut(); //~ ERROR: equivalent to `.iter_mut()
|
|
|
|
let _ = (&BTreeMap::<i32, u64>::new()).iter(); //~ ERROR: equivalent to `.iter()
|
|
|
|
let _ = (&mut BTreeMap::<i32, u64>::new()).iter_mut(); //~ ERROR: equivalent to `.iter_mut()
|
|
|
|
let _ = (&VecDeque::<i32>::new()).iter(); //~ ERROR: equivalent to `.iter()
|
|
|
|
let _ = (&mut VecDeque::<i32>::new()).iter_mut(); //~ ERROR: equivalent to `.iter_mut()
|
|
|
|
let _ = (&LinkedList::<i32>::new()).iter(); //~ ERROR: equivalent to `.iter()
|
|
|
|
let _ = (&mut LinkedList::<i32>::new()).iter_mut(); //~ ERROR: equivalent to `.iter_mut()
|
|
|
|
let _ = (&HashMap::<i32, u64>::new()).iter(); //~ ERROR: equivalent to `.iter()
|
|
|
|
let _ = (&mut HashMap::<i32, u64>::new()).iter_mut(); //~ ERROR: equivalent to `.iter_mut()
|
2019-01-13 05:52:51 -06:00
|
|
|
|
2023-07-02 07:35:19 -05:00
|
|
|
let _ = (&BTreeSet::<i32>::new()).iter(); //~ ERROR: equivalent to `.iter()
|
|
|
|
let _ = (&BinaryHeap::<i32>::new()).iter(); //~ ERROR: equivalent to `.iter()
|
|
|
|
let _ = (&HashSet::<i32>::new()).iter(); //~ ERROR: equivalent to `.iter()
|
|
|
|
let _ = std::path::Path::new("12/34").iter(); //~ ERROR: equivalent to `.iter()
|
|
|
|
let _ = std::path::PathBuf::from("12/34").iter(); //~ ERROR: equivalent to `.iter()
|
2020-06-09 09:36:01 -05:00
|
|
|
|
2023-07-02 07:35:19 -05:00
|
|
|
let _ = (&[1, 2, 3]).iter().next(); //~ ERROR: equivalent to `.iter()
|
2019-01-13 05:52:51 -06:00
|
|
|
}
|