Skip to content

Commit 4cb3ecc

Browse files
bors[bot]lnicola
andauthored
Merge #8200
8200: Use arrayvec 0.6 r=kjeremy a=lnicola Closes #8198 changelog skip Co-authored-by: Laurențiu Nicola <[email protected]>
2 parents 59fdd7c + bc5c865 commit 4cb3ecc

File tree

8 files changed

+22
-23
lines changed

8 files changed

+22
-23
lines changed

Cargo.lock

+4-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/hir/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ doctest = false
1313
log = "0.4.8"
1414
rustc-hash = "1.1.0"
1515
either = "1.5.3"
16-
arrayvec = "0.5.1"
16+
arrayvec = "0.6"
1717
itertools = "0.10.0"
1818
smallvec = "1.4.0"
1919

crates/hir/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2238,7 +2238,7 @@ pub enum ScopeDef {
22382238
}
22392239

22402240
impl ScopeDef {
2241-
pub fn all_items(def: PerNs) -> ArrayVec<[Self; 3]> {
2241+
pub fn all_items(def: PerNs) -> ArrayVec<Self, 3> {
22422242
let mut items = ArrayVec::new();
22432243

22442244
match (def.take_types(), def.take_values()) {

crates/hir_ty/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ doctest = false
1212
[dependencies]
1313
cov-mark = { version = "1.1", features = ["thread-local"] }
1414
itertools = "0.10.0"
15-
arrayvec = "0.5.1"
15+
arrayvec = "0.6"
1616
smallvec = "1.2.0"
1717
ena = "0.14.0"
1818
log = "0.4.8"

crates/hir_ty/src/display.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
//! FIXME: write short doc here
22
3-
use std::fmt;
3+
use std::{array, fmt};
44

5-
use arrayvec::ArrayVec;
65
use chalk_ir::Mutability;
76
use hir_def::{
87
db::DefDatabase,
@@ -669,8 +668,7 @@ fn fn_traits(db: &dyn DefDatabase, trait_: TraitId) -> impl Iterator<Item = Trai
669668
db.lang_item(krate, "fn_mut".into()),
670669
db.lang_item(krate, "fn_once".into()),
671670
];
672-
// FIXME: Replace ArrayVec when into_iter is a thing on arrays
673-
ArrayVec::from(fn_traits).into_iter().flatten().flat_map(|it| it.as_trait())
671+
array::IntoIter::new(fn_traits).into_iter().flatten().flat_map(|it| it.as_trait())
674672
}
675673

676674
pub fn write_bounds_like_dyn_trait_with_prefix(

crates/hir_ty/src/method_resolution.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -228,12 +228,12 @@ impl Ty {
228228
&self,
229229
db: &dyn HirDatabase,
230230
cur_crate: CrateId,
231-
) -> Option<ArrayVec<[CrateId; 2]>> {
231+
) -> Option<ArrayVec<CrateId, 2>> {
232232
// Types like slice can have inherent impls in several crates, (core and alloc).
233233
// The corresponding impls are marked with lang items, so we can use them to find the required crates.
234234
macro_rules! lang_item_crate {
235235
($($name:expr),+ $(,)?) => {{
236-
let mut v = ArrayVec::<[LangItemTarget; 2]>::new();
236+
let mut v = ArrayVec::<LangItemTarget, 2>::new();
237237
$(
238238
v.extend(db.lang_item(cur_crate, $name.into()));
239239
)+

crates/syntax/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ itertools = "0.10.0"
1616
rowan = "0.13.0-pre.3"
1717
rustc_lexer = { version = "710.0.0", package = "rustc-ap-rustc_lexer" }
1818
rustc-hash = "1.1.0"
19-
arrayvec = "0.5.1"
19+
arrayvec = "0.6"
2020
once_cell = "1.3.1"
2121
indexmap = "1.4.0"
2222
smol_str = { version = "0.1.15", features = ["serde"] }

crates/syntax/src/ast/edit.rs

+10-11
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
//! immutable, all function here return a fresh copy of the tree, instead of
33
//! doing an in-place modification.
44
use std::{
5-
fmt, iter,
5+
array, fmt, iter,
66
ops::{self, RangeInclusive},
77
};
88

@@ -32,7 +32,7 @@ impl ast::BinExpr {
3232
impl ast::Fn {
3333
#[must_use]
3434
pub fn with_body(&self, body: ast::BlockExpr) -> ast::Fn {
35-
let mut to_insert: ArrayVec<[SyntaxElement; 2]> = ArrayVec::new();
35+
let mut to_insert: ArrayVec<SyntaxElement, 2> = ArrayVec::new();
3636
let old_body_or_semi: SyntaxElement = if let Some(old_body) = self.body() {
3737
old_body.syntax().clone().into()
3838
} else if let Some(semi) = self.semicolon_token() {
@@ -55,9 +55,8 @@ impl ast::Fn {
5555

5656
let anchor = self.name().expect("The function must have a name").syntax().clone();
5757

58-
let mut to_insert: ArrayVec<[SyntaxElement; 1]> = ArrayVec::new();
59-
to_insert.push(generic_args.syntax().clone().into());
60-
self.insert_children(InsertPosition::After(anchor.into()), to_insert)
58+
let to_insert = [generic_args.syntax().clone().into()];
59+
self.insert_children(InsertPosition::After(anchor.into()), array::IntoIter::new(to_insert))
6160
}
6261
}
6362

@@ -96,7 +95,7 @@ where
9695
impl ast::Impl {
9796
#[must_use]
9897
pub fn with_assoc_item_list(&self, items: ast::AssocItemList) -> ast::Impl {
99-
let mut to_insert: ArrayVec<[SyntaxElement; 2]> = ArrayVec::new();
98+
let mut to_insert: ArrayVec<SyntaxElement, 2> = ArrayVec::new();
10099
if let Some(old_items) = self.assoc_item_list() {
101100
let to_replace: SyntaxElement = old_items.syntax().clone().into();
102101
to_insert.push(items.syntax().clone().into());
@@ -141,7 +140,7 @@ impl ast::AssocItemList {
141140
},
142141
};
143142
let ws = tokens::WsBuilder::new(&format!("{}{}", whitespace, indent));
144-
let to_insert: ArrayVec<[SyntaxElement; 2]> =
143+
let to_insert: ArrayVec<SyntaxElement, 2> =
145144
[ws.ws().into(), item.syntax().clone().into()].into();
146145
self.insert_children(position, to_insert)
147146
}
@@ -192,7 +191,7 @@ impl ast::RecordExprFieldList {
192191
tokens::single_space()
193192
};
194193

195-
let mut to_insert: ArrayVec<[SyntaxElement; 4]> = ArrayVec::new();
194+
let mut to_insert: ArrayVec<SyntaxElement, 4> = ArrayVec::new();
196195
to_insert.push(space.into());
197196
to_insert.push(field.syntax().clone().into());
198197
to_insert.push(make::token(T![,]).into());
@@ -305,7 +304,7 @@ impl ast::PathSegment {
305304
iter::once(type_args.syntax().clone().into()),
306305
);
307306
}
308-
let mut to_insert: ArrayVec<[SyntaxElement; 2]> = ArrayVec::new();
307+
let mut to_insert: ArrayVec<SyntaxElement, 2> = ArrayVec::new();
309308
if turbo {
310309
to_insert.push(make::token(T![::]).into());
311310
}
@@ -444,7 +443,7 @@ impl ast::MatchArmList {
444443
let arm_ws = tokens::WsBuilder::new(" ");
445444
let match_indent = &leading_indent(self.syntax()).unwrap_or_default();
446445
let match_ws = tokens::WsBuilder::new(&format!("\n{}", match_indent));
447-
let to_insert: ArrayVec<[SyntaxElement; 3]> =
446+
let to_insert: ArrayVec<SyntaxElement, 3> =
448447
[arm_ws.ws().into(), item.syntax().clone().into(), match_ws.ws().into()].into();
449448
self.insert_children(position, to_insert)
450449
}
@@ -465,7 +464,7 @@ impl ast::GenericParamList {
465464
pub fn append_param(&self, item: ast::GenericParam) -> ast::GenericParamList {
466465
let space = tokens::single_space();
467466

468-
let mut to_insert: ArrayVec<[SyntaxElement; 4]> = ArrayVec::new();
467+
let mut to_insert: ArrayVec<SyntaxElement, 4> = ArrayVec::new();
469468
if self.generic_params().next().is_some() {
470469
to_insert.push(space.into());
471470
}

0 commit comments

Comments
 (0)