mirror of
https://github.com/rust-lang/rust-analyzer
synced 2025-01-12 13:18:47 +00:00
Use arrayvec 0.6
This commit is contained in:
parent
59fdd7c84c
commit
9787bddac5
8 changed files with 20 additions and 20 deletions
6
Cargo.lock
generated
6
Cargo.lock
generated
|
@ -1,5 +1,7 @@
|
||||||
# This file is automatically @generated by Cargo.
|
# This file is automatically @generated by Cargo.
|
||||||
# It is not intended for manual editing.
|
# It is not intended for manual editing.
|
||||||
|
version = 3
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "addr2line"
|
name = "addr2line"
|
||||||
version = "0.14.1"
|
version = "0.14.1"
|
||||||
|
@ -47,9 +49,9 @@ checksum = "33954243bd79057c2de7338850b85983a44588021f8a5fee574a8888c6de4344"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "arrayvec"
|
name = "arrayvec"
|
||||||
version = "0.5.2"
|
version = "0.6.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "23b62fc65de8e4e7f52534fb52b0f3ed04746ae267519eef2a83941e8085068b"
|
checksum = "682f88bd1270f264991da8922b89ee1fb520b0da73f97c9f73cda54980123017"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "atty"
|
name = "atty"
|
||||||
|
|
|
@ -13,7 +13,7 @@ doctest = false
|
||||||
log = "0.4.8"
|
log = "0.4.8"
|
||||||
rustc-hash = "1.1.0"
|
rustc-hash = "1.1.0"
|
||||||
either = "1.5.3"
|
either = "1.5.3"
|
||||||
arrayvec = "0.5.1"
|
arrayvec = "0.6"
|
||||||
itertools = "0.10.0"
|
itertools = "0.10.0"
|
||||||
smallvec = "1.4.0"
|
smallvec = "1.4.0"
|
||||||
|
|
||||||
|
|
|
@ -2238,7 +2238,7 @@ pub enum ScopeDef {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ScopeDef {
|
impl ScopeDef {
|
||||||
pub fn all_items(def: PerNs) -> ArrayVec<[Self; 3]> {
|
pub fn all_items(def: PerNs) -> ArrayVec<Self, 3> {
|
||||||
let mut items = ArrayVec::new();
|
let mut items = ArrayVec::new();
|
||||||
|
|
||||||
match (def.take_types(), def.take_values()) {
|
match (def.take_types(), def.take_values()) {
|
||||||
|
|
|
@ -12,7 +12,7 @@ doctest = false
|
||||||
[dependencies]
|
[dependencies]
|
||||||
cov-mark = { version = "1.1", features = ["thread-local"] }
|
cov-mark = { version = "1.1", features = ["thread-local"] }
|
||||||
itertools = "0.10.0"
|
itertools = "0.10.0"
|
||||||
arrayvec = "0.5.1"
|
arrayvec = "0.6"
|
||||||
smallvec = "1.2.0"
|
smallvec = "1.2.0"
|
||||||
ena = "0.14.0"
|
ena = "0.14.0"
|
||||||
log = "0.4.8"
|
log = "0.4.8"
|
||||||
|
|
|
@ -1,8 +1,7 @@
|
||||||
//! FIXME: write short doc here
|
//! FIXME: write short doc here
|
||||||
|
|
||||||
use std::fmt;
|
use std::{array, fmt};
|
||||||
|
|
||||||
use arrayvec::ArrayVec;
|
|
||||||
use chalk_ir::Mutability;
|
use chalk_ir::Mutability;
|
||||||
use hir_def::{
|
use hir_def::{
|
||||||
db::DefDatabase,
|
db::DefDatabase,
|
||||||
|
@ -669,8 +668,7 @@ fn fn_traits(db: &dyn DefDatabase, trait_: TraitId) -> impl Iterator<Item = Trai
|
||||||
db.lang_item(krate, "fn_mut".into()),
|
db.lang_item(krate, "fn_mut".into()),
|
||||||
db.lang_item(krate, "fn_once".into()),
|
db.lang_item(krate, "fn_once".into()),
|
||||||
];
|
];
|
||||||
// FIXME: Replace ArrayVec when into_iter is a thing on arrays
|
array::IntoIter::new(fn_traits).into_iter().flatten().flat_map(|it| it.as_trait())
|
||||||
ArrayVec::from(fn_traits).into_iter().flatten().flat_map(|it| it.as_trait())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn write_bounds_like_dyn_trait_with_prefix(
|
pub fn write_bounds_like_dyn_trait_with_prefix(
|
||||||
|
|
|
@ -228,12 +228,12 @@ impl Ty {
|
||||||
&self,
|
&self,
|
||||||
db: &dyn HirDatabase,
|
db: &dyn HirDatabase,
|
||||||
cur_crate: CrateId,
|
cur_crate: CrateId,
|
||||||
) -> Option<ArrayVec<[CrateId; 2]>> {
|
) -> Option<ArrayVec<CrateId, 2>> {
|
||||||
// Types like slice can have inherent impls in several crates, (core and alloc).
|
// Types like slice can have inherent impls in several crates, (core and alloc).
|
||||||
// The corresponding impls are marked with lang items, so we can use them to find the required crates.
|
// The corresponding impls are marked with lang items, so we can use them to find the required crates.
|
||||||
macro_rules! lang_item_crate {
|
macro_rules! lang_item_crate {
|
||||||
($($name:expr),+ $(,)?) => {{
|
($($name:expr),+ $(,)?) => {{
|
||||||
let mut v = ArrayVec::<[LangItemTarget; 2]>::new();
|
let mut v = ArrayVec::<LangItemTarget, 2>::new();
|
||||||
$(
|
$(
|
||||||
v.extend(db.lang_item(cur_crate, $name.into()));
|
v.extend(db.lang_item(cur_crate, $name.into()));
|
||||||
)+
|
)+
|
||||||
|
|
|
@ -16,7 +16,7 @@ itertools = "0.10.0"
|
||||||
rowan = "0.13.0-pre.3"
|
rowan = "0.13.0-pre.3"
|
||||||
rustc_lexer = { version = "710.0.0", package = "rustc-ap-rustc_lexer" }
|
rustc_lexer = { version = "710.0.0", package = "rustc-ap-rustc_lexer" }
|
||||||
rustc-hash = "1.1.0"
|
rustc-hash = "1.1.0"
|
||||||
arrayvec = "0.5.1"
|
arrayvec = "0.6"
|
||||||
once_cell = "1.3.1"
|
once_cell = "1.3.1"
|
||||||
indexmap = "1.4.0"
|
indexmap = "1.4.0"
|
||||||
smol_str = { version = "0.1.15", features = ["serde"] }
|
smol_str = { version = "0.1.15", features = ["serde"] }
|
||||||
|
|
|
@ -32,7 +32,7 @@ impl ast::BinExpr {
|
||||||
impl ast::Fn {
|
impl ast::Fn {
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn with_body(&self, body: ast::BlockExpr) -> ast::Fn {
|
pub fn with_body(&self, body: ast::BlockExpr) -> ast::Fn {
|
||||||
let mut to_insert: ArrayVec<[SyntaxElement; 2]> = ArrayVec::new();
|
let mut to_insert: ArrayVec<SyntaxElement, 2> = ArrayVec::new();
|
||||||
let old_body_or_semi: SyntaxElement = if let Some(old_body) = self.body() {
|
let old_body_or_semi: SyntaxElement = if let Some(old_body) = self.body() {
|
||||||
old_body.syntax().clone().into()
|
old_body.syntax().clone().into()
|
||||||
} else if let Some(semi) = self.semicolon_token() {
|
} else if let Some(semi) = self.semicolon_token() {
|
||||||
|
@ -55,7 +55,7 @@ impl ast::Fn {
|
||||||
|
|
||||||
let anchor = self.name().expect("The function must have a name").syntax().clone();
|
let anchor = self.name().expect("The function must have a name").syntax().clone();
|
||||||
|
|
||||||
let mut to_insert: ArrayVec<[SyntaxElement; 1]> = ArrayVec::new();
|
let mut to_insert: ArrayVec<SyntaxElement, 1> = ArrayVec::new();
|
||||||
to_insert.push(generic_args.syntax().clone().into());
|
to_insert.push(generic_args.syntax().clone().into());
|
||||||
self.insert_children(InsertPosition::After(anchor.into()), to_insert)
|
self.insert_children(InsertPosition::After(anchor.into()), to_insert)
|
||||||
}
|
}
|
||||||
|
@ -96,7 +96,7 @@ where
|
||||||
impl ast::Impl {
|
impl ast::Impl {
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn with_assoc_item_list(&self, items: ast::AssocItemList) -> ast::Impl {
|
pub fn with_assoc_item_list(&self, items: ast::AssocItemList) -> ast::Impl {
|
||||||
let mut to_insert: ArrayVec<[SyntaxElement; 2]> = ArrayVec::new();
|
let mut to_insert: ArrayVec<SyntaxElement, 2> = ArrayVec::new();
|
||||||
if let Some(old_items) = self.assoc_item_list() {
|
if let Some(old_items) = self.assoc_item_list() {
|
||||||
let to_replace: SyntaxElement = old_items.syntax().clone().into();
|
let to_replace: SyntaxElement = old_items.syntax().clone().into();
|
||||||
to_insert.push(items.syntax().clone().into());
|
to_insert.push(items.syntax().clone().into());
|
||||||
|
@ -141,7 +141,7 @@ impl ast::AssocItemList {
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
let ws = tokens::WsBuilder::new(&format!("{}{}", whitespace, indent));
|
let ws = tokens::WsBuilder::new(&format!("{}{}", whitespace, indent));
|
||||||
let to_insert: ArrayVec<[SyntaxElement; 2]> =
|
let to_insert: ArrayVec<SyntaxElement, 2> =
|
||||||
[ws.ws().into(), item.syntax().clone().into()].into();
|
[ws.ws().into(), item.syntax().clone().into()].into();
|
||||||
self.insert_children(position, to_insert)
|
self.insert_children(position, to_insert)
|
||||||
}
|
}
|
||||||
|
@ -192,7 +192,7 @@ impl ast::RecordExprFieldList {
|
||||||
tokens::single_space()
|
tokens::single_space()
|
||||||
};
|
};
|
||||||
|
|
||||||
let mut to_insert: ArrayVec<[SyntaxElement; 4]> = ArrayVec::new();
|
let mut to_insert: ArrayVec<SyntaxElement, 4> = ArrayVec::new();
|
||||||
to_insert.push(space.into());
|
to_insert.push(space.into());
|
||||||
to_insert.push(field.syntax().clone().into());
|
to_insert.push(field.syntax().clone().into());
|
||||||
to_insert.push(make::token(T![,]).into());
|
to_insert.push(make::token(T![,]).into());
|
||||||
|
@ -305,7 +305,7 @@ impl ast::PathSegment {
|
||||||
iter::once(type_args.syntax().clone().into()),
|
iter::once(type_args.syntax().clone().into()),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
let mut to_insert: ArrayVec<[SyntaxElement; 2]> = ArrayVec::new();
|
let mut to_insert: ArrayVec<SyntaxElement, 2> = ArrayVec::new();
|
||||||
if turbo {
|
if turbo {
|
||||||
to_insert.push(make::token(T![::]).into());
|
to_insert.push(make::token(T![::]).into());
|
||||||
}
|
}
|
||||||
|
@ -444,7 +444,7 @@ impl ast::MatchArmList {
|
||||||
let arm_ws = tokens::WsBuilder::new(" ");
|
let arm_ws = tokens::WsBuilder::new(" ");
|
||||||
let match_indent = &leading_indent(self.syntax()).unwrap_or_default();
|
let match_indent = &leading_indent(self.syntax()).unwrap_or_default();
|
||||||
let match_ws = tokens::WsBuilder::new(&format!("\n{}", match_indent));
|
let match_ws = tokens::WsBuilder::new(&format!("\n{}", match_indent));
|
||||||
let to_insert: ArrayVec<[SyntaxElement; 3]> =
|
let to_insert: ArrayVec<SyntaxElement, 3> =
|
||||||
[arm_ws.ws().into(), item.syntax().clone().into(), match_ws.ws().into()].into();
|
[arm_ws.ws().into(), item.syntax().clone().into(), match_ws.ws().into()].into();
|
||||||
self.insert_children(position, to_insert)
|
self.insert_children(position, to_insert)
|
||||||
}
|
}
|
||||||
|
@ -465,7 +465,7 @@ impl ast::GenericParamList {
|
||||||
pub fn append_param(&self, item: ast::GenericParam) -> ast::GenericParamList {
|
pub fn append_param(&self, item: ast::GenericParam) -> ast::GenericParamList {
|
||||||
let space = tokens::single_space();
|
let space = tokens::single_space();
|
||||||
|
|
||||||
let mut to_insert: ArrayVec<[SyntaxElement; 4]> = ArrayVec::new();
|
let mut to_insert: ArrayVec<SyntaxElement, 4> = ArrayVec::new();
|
||||||
if self.generic_params().next().is_some() {
|
if self.generic_params().next().is_some() {
|
||||||
to_insert.push(space.into());
|
to_insert.push(space.into());
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue