]> git.proxmox.com Git - rustc.git/blob - src/tools/clippy/tests/ui/iter_cloned_collect.rs
New upstream version 1.53.0+dfsg1
[rustc.git] / src / tools / clippy / tests / ui / iter_cloned_collect.rs
1 // run-rustfix
2
3 #![allow(unused)]
4
5 use std::collections::HashSet;
6 use std::collections::VecDeque;
7
8 fn main() {
9 let v = [1, 2, 3, 4, 5];
10 let v2: Vec<isize> = v.iter().cloned().collect();
11 let v3: HashSet<isize> = v.iter().cloned().collect();
12 let v4: VecDeque<isize> = v.iter().cloned().collect();
13
14 // Handle macro expansion in suggestion
15 let _: Vec<isize> = vec![1, 2, 3].iter().cloned().collect();
16
17 // Issue #3704
18 unsafe {
19 let _: Vec<u8> = std::ffi::CStr::from_ptr(std::ptr::null())
20 .to_bytes()
21 .iter()
22 .cloned()
23 .collect();
24 }
25
26 // Issue #6808
27 let arr: [u8; 64] = [0; 64];
28 let _: Vec<_> = arr.iter().cloned().collect();
29 }