Skip to content

Commit 1597728

Browse files
committed
Auto merge of #88611 - m-ou-se:array-into-iter-new-deprecate, r=joshtriplett
Deprecate array::IntoIter::new.
2 parents cafc458 + 27d3935 commit 1597728

File tree

25 files changed

+69
-99
lines changed

25 files changed

+69
-99
lines changed

compiler/rustc_ast_lowering/src/lib.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,9 @@ use smallvec::SmallVec;
7070
use tracing::{debug, trace};
7171

7272
macro_rules! arena_vec {
73-
($this:expr; $($x:expr),*) => ({
74-
let a = [$($x),*];
75-
$this.arena.alloc_from_iter(std::array::IntoIter::new(a))
76-
});
73+
($this:expr; $($x:expr),*) => (
74+
$this.arena.alloc_from_iter([$($x),*])
75+
);
7776
}
7877

7978
mod asm;

compiler/rustc_codegen_cranelift/scripts/cargo.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ fn main() {
4242
"RUSTFLAGS",
4343
env::var("RUSTFLAGS").unwrap_or(String::new()) + " -Cprefer-dynamic",
4444
);
45-
std::array::IntoIter::new(["rustc".to_string()])
45+
IntoIterator::into_iter(["rustc".to_string()])
4646
.chain(env::args().skip(2))
4747
.chain([
4848
"--".to_string(),
@@ -56,7 +56,7 @@ fn main() {
5656
"RUSTFLAGS",
5757
env::var("RUSTFLAGS").unwrap_or(String::new()) + " -Cprefer-dynamic",
5858
);
59-
std::array::IntoIter::new(["rustc".to_string()])
59+
IntoIterator::into_iter(["rustc".to_string()])
6060
.chain(env::args().skip(2))
6161
.chain([
6262
"--".to_string(),

compiler/rustc_expand/src/proc_macro_server.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -466,13 +466,12 @@ impl server::TokenStream for Rustc<'_, '_> {
466466
ast::ExprKind::Unary(ast::UnOp::Neg, e) => match &e.kind {
467467
ast::ExprKind::Lit(l) => match l.token {
468468
token::Lit { kind: token::Integer | token::Float, .. } => {
469-
Ok(std::array::IntoIter::new([
469+
Ok(Self::TokenStream::from_iter([
470470
// FIXME: The span of the `-` token is lost when
471471
// parsing, so we cannot faithfully recover it here.
472472
tokenstream::TokenTree::token(token::BinOp(token::Minus), e.span),
473473
tokenstream::TokenTree::token(token::Literal(l.token), l.span),
474-
])
475-
.collect())
474+
]))
476475
}
477476
_ => Err(()),
478477
},

compiler/rustc_hir/src/def.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -443,11 +443,11 @@ impl<T> PerNS<T> {
443443
}
444444

445445
pub fn into_iter(self) -> IntoIter<T, 3> {
446-
IntoIter::new([self.value_ns, self.type_ns, self.macro_ns])
446+
[self.value_ns, self.type_ns, self.macro_ns].into_iter()
447447
}
448448

449449
pub fn iter(&self) -> IntoIter<&T, 3> {
450-
IntoIter::new([&self.value_ns, &self.type_ns, &self.macro_ns])
450+
[&self.value_ns, &self.type_ns, &self.macro_ns].into_iter()
451451
}
452452
}
453453

@@ -481,7 +481,7 @@ impl<T> PerNS<Option<T>> {
481481

482482
/// Returns an iterator over the items which are `Some`.
483483
pub fn present_items(self) -> impl Iterator<Item = T> {
484-
IntoIter::new([self.type_ns, self.value_ns, self.macro_ns]).flatten()
484+
[self.type_ns, self.value_ns, self.macro_ns].into_iter().flatten()
485485
}
486486
}
487487

compiler/rustc_session/src/filesearch.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ pub use self::FileMatch::*;
44

55
use std::env;
66
use std::fs;
7+
use std::iter::FromIterator;
78
use std::path::{Path, PathBuf};
89

910
use crate::search_paths::{PathKind, SearchPath, SearchPathFile};
@@ -91,8 +92,7 @@ impl<'a> FileSearch<'a> {
9192

9293
pub fn make_target_lib_path(sysroot: &Path, target_triple: &str) -> PathBuf {
9394
let rustlib_path = rustc_target::target_rustlib_path(sysroot, target_triple);
94-
std::array::IntoIter::new([sysroot, Path::new(&rustlib_path), Path::new("lib")])
95-
.collect::<PathBuf>()
95+
PathBuf::from_iter([sysroot, Path::new(&rustlib_path), Path::new("lib")])
9696
}
9797

9898
/// This function checks if sysroot is found using env::args().next(), and if it

compiler/rustc_session/src/session.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -792,12 +792,11 @@ impl Session {
792792
/// Returns a list of directories where target-specific tool binaries are located.
793793
pub fn get_tools_search_paths(&self, self_contained: bool) -> Vec<PathBuf> {
794794
let rustlib_path = rustc_target::target_rustlib_path(&self.sysroot, &config::host_triple());
795-
let p = std::array::IntoIter::new([
795+
let p = PathBuf::from_iter([
796796
Path::new(&self.sysroot),
797797
Path::new(&rustlib_path),
798798
Path::new("bin"),
799-
])
800-
.collect::<PathBuf>();
799+
]);
801800
if self_contained { vec![p.clone(), p.join("self-contained")] } else { vec![p] }
802801
}
803802

compiler/rustc_target/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#![feature(min_specialization)]
1717
#![feature(step_trait)]
1818

19+
use std::iter::FromIterator;
1920
use std::path::{Path, PathBuf};
2021

2122
#[macro_use]
@@ -47,12 +48,11 @@ const RUST_LIB_DIR: &str = "rustlib";
4748
/// `"lib*/rustlib/x86_64-unknown-linux-gnu"`.
4849
pub fn target_rustlib_path(sysroot: &Path, target_triple: &str) -> PathBuf {
4950
let libdir = find_libdir(sysroot);
50-
std::array::IntoIter::new([
51+
PathBuf::from_iter([
5152
Path::new(libdir.as_ref()),
5253
Path::new(RUST_LIB_DIR),
5354
Path::new(target_triple),
5455
])
55-
.collect::<PathBuf>()
5656
}
5757

5858
/// The name of the directory rustc expects libraries to be located.

compiler/rustc_target/src/spec/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ use rustc_serialize::json::{Json, ToJson};
4242
use rustc_span::symbol::{sym, Symbol};
4343
use std::collections::BTreeMap;
4444
use std::convert::TryFrom;
45+
use std::iter::FromIterator;
4546
use std::ops::{Deref, DerefMut};
4647
use std::path::{Path, PathBuf};
4748
use std::str::FromStr;
@@ -2173,12 +2174,11 @@ impl Target {
21732174
// Additionally look in the sysroot under `lib/rustlib/<triple>/target.json`
21742175
// as a fallback.
21752176
let rustlib_path = crate::target_rustlib_path(&sysroot, &target_triple);
2176-
let p = std::array::IntoIter::new([
2177+
let p = PathBuf::from_iter([
21772178
Path::new(sysroot),
21782179
Path::new(&rustlib_path),
21792180
Path::new("target.json"),
2180-
])
2181-
.collect::<PathBuf>();
2181+
]);
21822182
if p.is_file() {
21832183
return load_file(&p);
21842184
}

compiler/rustc_trait_selection/src/traits/object_safety.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ use rustc_span::symbol::Symbol;
2525
use rustc_span::{MultiSpan, Span};
2626
use smallvec::SmallVec;
2727

28-
use std::array;
2928
use std::iter;
3029
use std::ops::ControlFlow;
3130

@@ -692,11 +691,8 @@ fn receiver_is_dispatchable<'tcx>(
692691
.to_predicate(tcx)
693692
};
694693

695-
let caller_bounds: Vec<Predicate<'tcx>> = param_env
696-
.caller_bounds()
697-
.iter()
698-
.chain(array::IntoIter::new([unsize_predicate, trait_predicate]))
699-
.collect();
694+
let caller_bounds: Vec<Predicate<'tcx>> =
695+
param_env.caller_bounds().iter().chain([unsize_predicate, trait_predicate]).collect();
700696

701697
ty::ParamEnv::new(tcx.intern_predicates(&caller_bounds), param_env.reveal())
702698
};

compiler/rustc_typeck/src/astconv/mod.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ use rustc_trait_selection::traits::error_reporting::report_object_safety_error;
3535
use rustc_trait_selection::traits::wf::object_region_bounds;
3636

3737
use smallvec::SmallVec;
38-
use std::array;
3938
use std::collections::BTreeSet;
4039
use std::slice;
4140

@@ -1635,7 +1634,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
16351634
debug!("one_bound_for_assoc_type: bound2 = {:?}", bound2);
16361635

16371636
let is_equality = is_equality();
1638-
let bounds = array::IntoIter::new([bound, bound2]).chain(matching_candidates);
1637+
let bounds = IntoIterator::into_iter([bound, bound2]).chain(matching_candidates);
16391638
let mut err = if is_equality.is_some() {
16401639
// More specific Error Index entry.
16411640
struct_span_err!(

0 commit comments

Comments
 (0)