]> git.lizzy.rs Git - rust.git/blobdiff - tests/ui/infinite_iter.rs
Addition `manual_map` test for `unsafe` blocks
[rust.git] / tests / ui / infinite_iter.rs
index 8f41e3ae98d9cf67d8012c7dde3ef007594c14cf..1fe688977659d962c5535b4127df8cf546c4852a 100644 (file)
@@ -1,14 +1,4 @@
-// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
 use std::iter::repeat;
-#[allow(clippy::trivially_copy_pass_by_ref)]
 fn square_is_lower_64(x: &u32) -> bool {
     x * x < 64
 }
@@ -58,3 +48,22 @@ fn main() {
     infinite_iters();
     potential_infinite_iters();
 }
+
+mod finite_collect {
+    use std::collections::HashSet;
+    use std::iter::FromIterator;
+
+    struct C;
+    impl FromIterator<i32> for C {
+        fn from_iter<I: IntoIterator<Item = i32>>(iter: I) -> Self {
+            C
+        }
+    }
+
+    fn check_collect() {
+        let _: HashSet<i32> = (0..).collect(); // Infinite iter
+
+        // Some data structures don't collect infinitely, such as `ArrayVec`
+        let _: C = (0..).collect();
+    }
+}