about summary refs log tree commit diff
path: root/compiler
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2021-12-05 12:53:01 +0000
committerbors <bors@rust-lang.org>2021-12-05 12:53:01 +0000
commit1597728ef5820d3ffcb9d3f0c890ef7802398751 (patch)
tree1a86c2a2cb56d502776e6cc3936ec683efb62ffb /compiler
parentcafc4582e66c478b6b297ae85b225c788106015e (diff)
parent27d39357b7052d96e1b3903518841d14534c38cf (diff)
Auto merge of #88611 - m-ou-se:array-into-iter-new-deprecate, r=joshtriplett
Deprecate array::IntoIter::new.
Diffstat (limited to 'compiler')
-rw-r--r--compiler/rustc_ast_lowering/src/lib.rs7
-rw-r--r--compiler/rustc_codegen_cranelift/scripts/cargo.rs4
-rw-r--r--compiler/rustc_expand/src/proc_macro_server.rs5
-rw-r--r--compiler/rustc_hir/src/def.rs6
-rw-r--r--compiler/rustc_session/src/filesearch.rs4
-rw-r--r--compiler/rustc_session/src/session.rs5
-rw-r--r--compiler/rustc_target/src/lib.rs4
-rw-r--r--compiler/rustc_target/src/spec/mod.rs6
-rw-r--r--compiler/rustc_trait_selection/src/traits/object_safety.rs8
-rw-r--r--compiler/rustc_typeck/src/astconv/mod.rs3
-rw-r--r--compiler/rustc_typeck/src/check/wfcheck.rs2
11 files changed, 23 insertions, 31 deletions
diff --git a/compiler/rustc_ast_lowering/src/lib.rs b/compiler/rustc_ast_lowering/src/lib.rs
index 1a4f0a26f2b..d0fbc2d0f11 100644
--- a/compiler/rustc_ast_lowering/src/lib.rs
+++ b/compiler/rustc_ast_lowering/src/lib.rs
@@ -70,10 +70,9 @@ use smallvec::SmallVec;
 use tracing::{debug, trace};
 
 macro_rules! arena_vec {
-    ($this:expr; $($x:expr),*) => ({
-        let a = [$($x),*];
-        $this.arena.alloc_from_iter(std::array::IntoIter::new(a))
-    });
+    ($this:expr; $($x:expr),*) => (
+        $this.arena.alloc_from_iter([$($x),*])
+    );
 }
 
 mod asm;
diff --git a/compiler/rustc_codegen_cranelift/scripts/cargo.rs b/compiler/rustc_codegen_cranelift/scripts/cargo.rs
index 89ec8da77d3..41d82b581cd 100644
--- a/compiler/rustc_codegen_cranelift/scripts/cargo.rs
+++ b/compiler/rustc_codegen_cranelift/scripts/cargo.rs
@@ -42,7 +42,7 @@ fn main() {
                 "RUSTFLAGS",
                 env::var("RUSTFLAGS").unwrap_or(String::new()) + " -Cprefer-dynamic",
             );
-            std::array::IntoIter::new(["rustc".to_string()])
+            IntoIterator::into_iter(["rustc".to_string()])
                 .chain(env::args().skip(2))
                 .chain([
                     "--".to_string(),
@@ -56,7 +56,7 @@ fn main() {
                 "RUSTFLAGS",
                 env::var("RUSTFLAGS").unwrap_or(String::new()) + " -Cprefer-dynamic",
             );
-            std::array::IntoIter::new(["rustc".to_string()])
+            IntoIterator::into_iter(["rustc".to_string()])
                 .chain(env::args().skip(2))
                 .chain([
                     "--".to_string(),
diff --git a/compiler/rustc_expand/src/proc_macro_server.rs b/compiler/rustc_expand/src/proc_macro_server.rs
index fa9e98be9e8..b7e47e4da6f 100644
--- a/compiler/rustc_expand/src/proc_macro_server.rs
+++ b/compiler/rustc_expand/src/proc_macro_server.rs
@@ -466,13 +466,12 @@ impl server::TokenStream for Rustc<'_, '_> {
             ast::ExprKind::Unary(ast::UnOp::Neg, e) => match &e.kind {
                 ast::ExprKind::Lit(l) => match l.token {
                     token::Lit { kind: token::Integer | token::Float, .. } => {
-                        Ok(std::array::IntoIter::new([
+                        Ok(Self::TokenStream::from_iter([
                             // FIXME: The span of the `-` token is lost when
                             // parsing, so we cannot faithfully recover it here.
                             tokenstream::TokenTree::token(token::BinOp(token::Minus), e.span),
                             tokenstream::TokenTree::token(token::Literal(l.token), l.span),
-                        ])
-                        .collect())
+                        ]))
                     }
                     _ => Err(()),
                 },
diff --git a/compiler/rustc_hir/src/def.rs b/compiler/rustc_hir/src/def.rs
index 60761a05de8..405aaf1f4e5 100644
--- a/compiler/rustc_hir/src/def.rs
+++ b/compiler/rustc_hir/src/def.rs
@@ -443,11 +443,11 @@ impl<T> PerNS<T> {
     }
 
     pub fn into_iter(self) -> IntoIter<T, 3> {
-        IntoIter::new([self.value_ns, self.type_ns, self.macro_ns])
+        [self.value_ns, self.type_ns, self.macro_ns].into_iter()
     }
 
     pub fn iter(&self) -> IntoIter<&T, 3> {
-        IntoIter::new([&self.value_ns, &self.type_ns, &self.macro_ns])
+        [&self.value_ns, &self.type_ns, &self.macro_ns].into_iter()
     }
 }
 
@@ -481,7 +481,7 @@ impl<T> PerNS<Option<T>> {
 
     /// Returns an iterator over the items which are `Some`.
     pub fn present_items(self) -> impl Iterator<Item = T> {
-        IntoIter::new([self.type_ns, self.value_ns, self.macro_ns]).flatten()
+        [self.type_ns, self.value_ns, self.macro_ns].into_iter().flatten()
     }
 }
 
diff --git a/compiler/rustc_session/src/filesearch.rs b/compiler/rustc_session/src/filesearch.rs
index 9359a55e55a..357190178ce 100644
--- a/compiler/rustc_session/src/filesearch.rs
+++ b/compiler/rustc_session/src/filesearch.rs
@@ -4,6 +4,7 @@ pub use self::FileMatch::*;
 
 use std::env;
 use std::fs;
+use std::iter::FromIterator;
 use std::path::{Path, PathBuf};
 
 use crate::search_paths::{PathKind, SearchPath, SearchPathFile};
@@ -91,8 +92,7 @@ impl<'a> FileSearch<'a> {
 
 pub fn make_target_lib_path(sysroot: &Path, target_triple: &str) -> PathBuf {
     let rustlib_path = rustc_target::target_rustlib_path(sysroot, target_triple);
-    std::array::IntoIter::new([sysroot, Path::new(&rustlib_path), Path::new("lib")])
-        .collect::<PathBuf>()
+    PathBuf::from_iter([sysroot, Path::new(&rustlib_path), Path::new("lib")])
 }
 
 /// This function checks if sysroot is found using env::args().next(), and if it
diff --git a/compiler/rustc_session/src/session.rs b/compiler/rustc_session/src/session.rs
index 52a92de842f..e37d504135d 100644
--- a/compiler/rustc_session/src/session.rs
+++ b/compiler/rustc_session/src/session.rs
@@ -792,12 +792,11 @@ impl Session {
     /// Returns a list of directories where target-specific tool binaries are located.
     pub fn get_tools_search_paths(&self, self_contained: bool) -> Vec<PathBuf> {
         let rustlib_path = rustc_target::target_rustlib_path(&self.sysroot, &config::host_triple());
-        let p = std::array::IntoIter::new([
+        let p = PathBuf::from_iter([
             Path::new(&self.sysroot),
             Path::new(&rustlib_path),
             Path::new("bin"),
-        ])
-        .collect::<PathBuf>();
+        ]);
         if self_contained { vec![p.clone(), p.join("self-contained")] } else { vec![p] }
     }
 
diff --git a/compiler/rustc_target/src/lib.rs b/compiler/rustc_target/src/lib.rs
index 23d5d575d94..b18d17c1b7d 100644
--- a/compiler/rustc_target/src/lib.rs
+++ b/compiler/rustc_target/src/lib.rs
@@ -16,6 +16,7 @@
 #![feature(min_specialization)]
 #![feature(step_trait)]
 
+use std::iter::FromIterator;
 use std::path::{Path, PathBuf};
 
 #[macro_use]
@@ -47,12 +48,11 @@ const RUST_LIB_DIR: &str = "rustlib";
 /// `"lib*/rustlib/x86_64-unknown-linux-gnu"`.
 pub fn target_rustlib_path(sysroot: &Path, target_triple: &str) -> PathBuf {
     let libdir = find_libdir(sysroot);
-    std::array::IntoIter::new([
+    PathBuf::from_iter([
         Path::new(libdir.as_ref()),
         Path::new(RUST_LIB_DIR),
         Path::new(target_triple),
     ])
-    .collect::<PathBuf>()
 }
 
 /// The name of the directory rustc expects libraries to be located.
diff --git a/compiler/rustc_target/src/spec/mod.rs b/compiler/rustc_target/src/spec/mod.rs
index 0d49c7f6ee8..72d9b501545 100644
--- a/compiler/rustc_target/src/spec/mod.rs
+++ b/compiler/rustc_target/src/spec/mod.rs
@@ -42,6 +42,7 @@ use rustc_serialize::json::{Json, ToJson};
 use rustc_span::symbol::{sym, Symbol};
 use std::collections::BTreeMap;
 use std::convert::TryFrom;
+use std::iter::FromIterator;
 use std::ops::{Deref, DerefMut};
 use std::path::{Path, PathBuf};
 use std::str::FromStr;
@@ -2173,12 +2174,11 @@ impl Target {
                 // Additionally look in the sysroot under `lib/rustlib/<triple>/target.json`
                 // as a fallback.
                 let rustlib_path = crate::target_rustlib_path(&sysroot, &target_triple);
-                let p = std::array::IntoIter::new([
+                let p = PathBuf::from_iter([
                     Path::new(sysroot),
                     Path::new(&rustlib_path),
                     Path::new("target.json"),
-                ])
-                .collect::<PathBuf>();
+                ]);
                 if p.is_file() {
                     return load_file(&p);
                 }
diff --git a/compiler/rustc_trait_selection/src/traits/object_safety.rs b/compiler/rustc_trait_selection/src/traits/object_safety.rs
index afc546540d2..2ad8dc82a84 100644
--- a/compiler/rustc_trait_selection/src/traits/object_safety.rs
+++ b/compiler/rustc_trait_selection/src/traits/object_safety.rs
@@ -25,7 +25,6 @@ use rustc_span::symbol::Symbol;
 use rustc_span::{MultiSpan, Span};
 use smallvec::SmallVec;
 
-use std::array;
 use std::iter;
 use std::ops::ControlFlow;
 
@@ -692,11 +691,8 @@ fn receiver_is_dispatchable<'tcx>(
                 .to_predicate(tcx)
         };
 
-        let caller_bounds: Vec<Predicate<'tcx>> = param_env
-            .caller_bounds()
-            .iter()
-            .chain(array::IntoIter::new([unsize_predicate, trait_predicate]))
-            .collect();
+        let caller_bounds: Vec<Predicate<'tcx>> =
+            param_env.caller_bounds().iter().chain([unsize_predicate, trait_predicate]).collect();
 
         ty::ParamEnv::new(tcx.intern_predicates(&caller_bounds), param_env.reveal())
     };
diff --git a/compiler/rustc_typeck/src/astconv/mod.rs b/compiler/rustc_typeck/src/astconv/mod.rs
index da751f20753..08261fedd4a 100644
--- a/compiler/rustc_typeck/src/astconv/mod.rs
+++ b/compiler/rustc_typeck/src/astconv/mod.rs
@@ -35,7 +35,6 @@ use rustc_trait_selection::traits::error_reporting::report_object_safety_error;
 use rustc_trait_selection::traits::wf::object_region_bounds;
 
 use smallvec::SmallVec;
-use std::array;
 use std::collections::BTreeSet;
 use std::slice;
 
@@ -1635,7 +1634,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
             debug!("one_bound_for_assoc_type: bound2 = {:?}", bound2);
 
             let is_equality = is_equality();
-            let bounds = array::IntoIter::new([bound, bound2]).chain(matching_candidates);
+            let bounds = IntoIterator::into_iter([bound, bound2]).chain(matching_candidates);
             let mut err = if is_equality.is_some() {
                 // More specific Error Index entry.
                 struct_span_err!(
diff --git a/compiler/rustc_typeck/src/check/wfcheck.rs b/compiler/rustc_typeck/src/check/wfcheck.rs
index 33a0c3275ca..1fc88829c77 100644
--- a/compiler/rustc_typeck/src/check/wfcheck.rs
+++ b/compiler/rustc_typeck/src/check/wfcheck.rs
@@ -1822,7 +1822,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
                 // Inherent impl: take implied bounds from the `self` type.
                 let self_ty = self.tcx.type_of(impl_def_id);
                 let self_ty = self.normalize_associated_types_in(span, self_ty);
-                std::array::IntoIter::new([self_ty]).collect()
+                FxHashSet::from_iter([self_ty])
             }
         }
     }