Skip to content

Commit ca44b68

Browse files
committed
Use array IntoIter
1 parent 56fbf5d commit ca44b68

File tree

13 files changed

+33
-32
lines changed

13 files changed

+33
-32
lines changed

crates/base_db/src/fixture.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ pub fn mirror(input: TokenStream) -> TokenStream {
283283
input
284284
}
285285
"#;
286-
let proc_macros = std::array::IntoIter::new([
286+
let proc_macros = [
287287
ProcMacro {
288288
name: "identity".into(),
289289
kind: crate::ProcMacroKind::Attr,
@@ -304,7 +304,8 @@ pub fn mirror(input: TokenStream) -> TokenStream {
304304
kind: crate::ProcMacroKind::FuncLike,
305305
expander: Arc::new(MirrorProcMacroExpander),
306306
},
307-
])
307+
]
308+
.into_iter()
308309
.filter(|pm| proc_macros.iter().any(|name| name == pm.name))
309310
.collect();
310311
(proc_macros, source.into())

crates/hir/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2392,7 +2392,7 @@ impl Type {
23922392
}
23932393
.cast(&Interner),
23942394
),
2395-
[TyVariableKind::General].iter().copied(),
2395+
[TyVariableKind::General].into_iter(),
23962396
);
23972397

23982398
match db.trait_solve(self.krate, goal)? {

crates/hir_def/src/nameres/collector.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -507,12 +507,12 @@ impl DefCollector<'_> {
507507
};
508508
let path = ModPath::from_segments(
509509
path_kind.clone(),
510-
[krate.clone(), name![prelude], edition].iter().cloned(),
510+
[krate.clone(), name![prelude], edition].into_iter(),
511511
);
512512
// Fall back to the older `std::prelude::v1` for compatibility with Rust <1.52.0
513513
// FIXME remove this fallback
514514
let fallback_path =
515-
ModPath::from_segments(path_kind, [krate, name![prelude], name![v1]].iter().cloned());
515+
ModPath::from_segments(path_kind, [krate, name![prelude], name![v1]].into_iter());
516516

517517
for path in &[path, fallback_path] {
518518
let (per_ns, _) = self.def_map.resolve_path(

crates/hir_ty/src/utils.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//! Helper functions for working with def, which don't need to be a separate
22
//! query, but can't be computed directly from `*Data` (ie, which need a `db`).
33
4-
use std::{array, iter};
4+
use std::iter;
55

66
use base_db::CrateId;
77
use chalk_ir::{fold::Shift, BoundVar, DebruijnIndex};
@@ -25,12 +25,14 @@ use crate::{
2525
};
2626

2727
pub(crate) fn fn_traits(db: &dyn DefDatabase, krate: CrateId) -> impl Iterator<Item = TraitId> {
28-
let fn_traits = [
28+
[
2929
db.lang_item(krate, "fn".into()),
3030
db.lang_item(krate, "fn_mut".into()),
3131
db.lang_item(krate, "fn_once".into()),
32-
];
33-
array::IntoIter::new(fn_traits).into_iter().flatten().flat_map(|it| it.as_trait())
32+
]
33+
.into_iter()
34+
.flatten()
35+
.flat_map(|it| it.as_trait())
3436
}
3537

3638
fn direct_super_traits(db: &dyn DefDatabase, trait_: TraitId) -> Vec<TraitId> {

crates/ide_assists/src/handlers/replace_try_expr_with_match.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,7 @@ pub(crate) fn replace_try_expr_with_match(acc: &mut Assists, ctx: &AssistContext
7676
);
7777
let sad_arm = make::match_arm(iter::once(sad_pat), None, sad_expr);
7878

79-
let match_arms = [happy_arm, sad_arm];
80-
let match_arm_list = make::match_arm_list(std::array::IntoIter::new(match_arms));
79+
let match_arm_list = make::match_arm_list([happy_arm, sad_arm]);
8180

8281
let expr_match = make::expr_match(expr, match_arm_list)
8382
.indent(IndentLevel::from_node(qm_kw_parent.syntax()));

crates/ide_assists/src/utils.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ fn invert_special_case(expr: &ast::Expr) -> Option<ast::Expr> {
268268
}
269269

270270
pub(crate) fn next_prev() -> impl Iterator<Item = Direction> {
271-
[Direction::Next, Direction::Prev].iter().copied()
271+
[Direction::Next, Direction::Prev].into_iter()
272272
}
273273

274274
pub(crate) fn does_pat_match_variant(pat: &ast::Pat, var: &ast::Pat) -> bool {

crates/ide_completion/src/completions/attribute.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ macro_rules! attrs {
177177
#[rustfmt::skip]
178178
static KIND_TO_ATTRIBUTES: Lazy<FxHashMap<SyntaxKind, &[&str]>> = Lazy::new(|| {
179179
use SyntaxKind::*;
180-
std::array::IntoIter::new([
180+
[
181181
(
182182
SOURCE_FILE,
183183
attrs!(
@@ -229,7 +229,8 @@ static KIND_TO_ATTRIBUTES: Lazy<FxHashMap<SyntaxKind, &[&str]>> = Lazy::new(|| {
229229
(MATCH_ARM, attrs!()),
230230
(IDENT_PAT, attrs!()),
231231
(RECORD_PAT_FIELD, attrs!()),
232-
])
232+
]
233+
.into_iter()
233234
.collect()
234235
});
235236
const EXPR_ATTRIBUTES: &[&str] = attrs!();

crates/ide_completion/src/completions/attribute/cfg.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ use crate::{
1010
};
1111

1212
pub(crate) fn complete_cfg(acc: &mut Completions, ctx: &CompletionContext) {
13-
let add_completion = |item: &&str| {
13+
let add_completion = |item: &str| {
1414
let mut completion =
15-
CompletionItem::new(CompletionKind::Attribute, ctx.source_range(), *item);
15+
CompletionItem::new(CompletionKind::Attribute, ctx.source_range(), item);
1616
completion.insert_text(format!(r#""{}""#, item));
1717
completion.kind(CompletionItemKind::Attribute);
1818
acc.add(completion.build());
@@ -26,11 +26,11 @@ pub(crate) fn complete_cfg(acc: &mut Completions, ctx: &CompletionContext) {
2626
.find(|t| matches!(t.kind(), SyntaxKind::IDENT));
2727

2828
match previous.as_ref().map(|p| p.text()) {
29-
Some("target_arch") => KNOWN_ARCH.iter().for_each(add_completion),
30-
Some("target_env") => KNOWN_ENV.iter().for_each(add_completion),
31-
Some("target_os") => KNOWN_OS.iter().for_each(add_completion),
32-
Some("target_vendor") => KNOWN_VENDOR.iter().for_each(add_completion),
33-
Some("target_endian") => ["little", "big"].iter().for_each(add_completion),
29+
Some("target_arch") => KNOWN_ARCH.iter().copied().for_each(add_completion),
30+
Some("target_env") => KNOWN_ENV.iter().copied().for_each(add_completion),
31+
Some("target_os") => KNOWN_OS.iter().copied().for_each(add_completion),
32+
Some("target_vendor") => KNOWN_VENDOR.iter().copied().for_each(add_completion),
33+
Some("target_endian") => ["little", "big"].into_iter().for_each(add_completion),
3434
Some(name) => {
3535
if let Some(krate) = ctx.krate {
3636
krate.potential_cfg(ctx.db).get_cfg_values(&name).iter().for_each(|s| {

crates/ide_completion/src/completions/unqualified_path.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,10 @@ pub(crate) fn complete_unqualified_path(acc: &mut Completions, ctx: &CompletionC
1919
}
2020
});
2121

22-
std::array::IntoIter::new(["self::", "super::", "crate::"])
23-
.for_each(|kw| acc.add_keyword(ctx, kw));
22+
["self::", "super::", "crate::"].into_iter().for_each(|kw| acc.add_keyword(ctx, kw));
2423
return;
2524
}
26-
std::array::IntoIter::new(["self", "super", "crate"]).for_each(|kw| acc.add_keyword(ctx, kw));
25+
["self", "super", "crate"].into_iter().for_each(|kw| acc.add_keyword(ctx, kw));
2726

2827
match &ctx.completion_location {
2928
Some(ImmediateLocation::Visibility(_)) => return,

crates/proc_macro_srv/src/abis/abi_1_56/proc_macro/quote.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,7 @@ macro_rules! quote_ts {
2828
[
2929
TokenTree::from(Punct::new(':', Spacing::Joint)),
3030
TokenTree::from(Punct::new(':', Spacing::Alone)),
31-
].iter()
32-
.cloned()
31+
].into_iter()
3332
.map(|mut x| {
3433
x.set_span(Span::def_site());
3534
x
@@ -52,7 +51,7 @@ macro_rules! quote {
5251
($($t:tt)*) => {
5352
[
5453
$(TokenStream::from(quote_ts!($t)),)*
55-
].iter().cloned().collect::<TokenStream>()
54+
].into_iter().collect::<TokenStream>()
5655
};
5756
}
5857

crates/project_model/src/rustc_cfg.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ pub(crate) fn get(cargo_toml: Option<&ManifestPath>, target: Option<&str>) -> Ve
1212

1313
// Some nightly-only cfgs, which are required for stdlib
1414
res.push(CfgFlag::Atom("target_thread_local".into()));
15-
for &ty in ["8", "16", "32", "64", "cas", "ptr"].iter() {
16-
for &key in ["target_has_atomic", "target_has_atomic_load_store"].iter() {
15+
for ty in ["8", "16", "32", "64", "cas", "ptr"] {
16+
for key in ["target_has_atomic", "target_has_atomic_load_store"] {
1717
res.push(CfgFlag::KeyValue { key: key.to_string(), value: ty.into() });
1818
}
1919
}

crates/rust-analyzer/src/handlers.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -706,7 +706,7 @@ pub(crate) fn handle_runnables(
706706
let config = snap.config.runnables();
707707
match cargo_spec {
708708
Some(spec) => {
709-
for &cmd in ["check", "test"].iter() {
709+
for cmd in ["check", "test"] {
710710
res.push(lsp_ext::Runnable {
711711
label: format!("cargo {} -p {} --all-targets", cmd, spec.package),
712712
location: None,

crates/rust-analyzer/tests/slow-tests/sourcegen.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,12 @@ impl Feature {
5656

5757
fn is_valid_feature_name(feature: &str) -> Result<(), String> {
5858
'word: for word in feature.split_whitespace() {
59-
for &short in ["to", "and"].iter() {
59+
for short in ["to", "and"] {
6060
if word == short {
6161
continue 'word;
6262
}
6363
}
64-
for &short in ["To", "And"].iter() {
64+
for short in ["To", "And"] {
6565
if word == short {
6666
return Err(format!("Don't capitalize {:?}", word));
6767
}

0 commit comments

Comments
 (0)