about summary refs log tree commit diff
path: root/tests
diff options
context:
space:
mode:
authorMateusz Gacek <96mateusz.gacek@gmail.com>2021-04-26 13:03:51 -0700
committerMateusz Gacek <96mateusz.gacek@gmail.com>2021-04-26 13:03:51 -0700
commitd7627dcfc8a60aaedccf002738dc44a2576fa8fd (patch)
treef9084e128d9688dc948325a0973a6db1bb782c06 /tests
parenta362a4d1d0edb66aef186c1d27b28c60573078f4 (diff)
Fix FN in `iter_cloned_collect` with a large array
Diffstat (limited to 'tests')
-rw-r--r--tests/ui/iter_cloned_collect.fixed4
-rw-r--r--tests/ui/iter_cloned_collect.rs4
-rw-r--r--tests/ui/iter_cloned_collect.stderr8
3 files changed, 15 insertions, 1 deletions
diff --git a/tests/ui/iter_cloned_collect.fixed b/tests/ui/iter_cloned_collect.fixed
index 2773227e26b..39cc58cd298 100644
--- a/tests/ui/iter_cloned_collect.fixed
+++ b/tests/ui/iter_cloned_collect.fixed
@@ -19,4 +19,8 @@ fn main() {
         let _: Vec<u8> = std::ffi::CStr::from_ptr(std::ptr::null())
             .to_bytes().to_vec();
     }
+
+    // Issue #6808
+    let arr: [u8; 64] = [0; 64];
+    let _: Vec<_> = arr.to_vec();
 }
diff --git a/tests/ui/iter_cloned_collect.rs b/tests/ui/iter_cloned_collect.rs
index 60a4eac23c7..c2a036ec09f 100644
--- a/tests/ui/iter_cloned_collect.rs
+++ b/tests/ui/iter_cloned_collect.rs
@@ -22,4 +22,8 @@ fn main() {
             .cloned()
             .collect();
     }
+
+    // Issue #6808
+    let arr: [u8; 64] = [0; 64];
+    let _: Vec<_> = arr.iter().cloned().collect();
 }
diff --git a/tests/ui/iter_cloned_collect.stderr b/tests/ui/iter_cloned_collect.stderr
index b90a1e6c919..e1df61794ce 100644
--- a/tests/ui/iter_cloned_collect.stderr
+++ b/tests/ui/iter_cloned_collect.stderr
@@ -22,5 +22,11 @@ LL | |             .cloned()
 LL | |             .collect();
    | |______________________^ help: try: `.to_vec()`
 
-error: aborting due to 3 previous errors
+error: called `iter().cloned().collect()` on a slice to create a `Vec`. Calling `to_vec()` is both faster and more readable
+  --> $DIR/iter_cloned_collect.rs:28:24
+   |
+LL |     let _: Vec<_> = arr.iter().cloned().collect();
+   |                        ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `.to_vec()`
+
+error: aborting due to 4 previous errors