Use array IntoIter
This commit is contained in:
parent
56fbf5d7b2
commit
ca44b6892e
13 changed files with 33 additions and 32 deletions
|
|
@ -177,7 +177,7 @@ macro_rules! attrs {
|
|||
#[rustfmt::skip]
|
||||
static KIND_TO_ATTRIBUTES: Lazy<FxHashMap<SyntaxKind, &[&str]>> = Lazy::new(|| {
|
||||
use SyntaxKind::*;
|
||||
std::array::IntoIter::new([
|
||||
[
|
||||
(
|
||||
SOURCE_FILE,
|
||||
attrs!(
|
||||
|
|
@ -229,7 +229,8 @@ static KIND_TO_ATTRIBUTES: Lazy<FxHashMap<SyntaxKind, &[&str]>> = Lazy::new(|| {
|
|||
(MATCH_ARM, attrs!()),
|
||||
(IDENT_PAT, attrs!()),
|
||||
(RECORD_PAT_FIELD, attrs!()),
|
||||
])
|
||||
]
|
||||
.into_iter()
|
||||
.collect()
|
||||
});
|
||||
const EXPR_ATTRIBUTES: &[&str] = attrs!();
|
||||
|
|
|
|||
|
|
@ -10,9 +10,9 @@ use crate::{
|
|||
};
|
||||
|
||||
pub(crate) fn complete_cfg(acc: &mut Completions, ctx: &CompletionContext) {
|
||||
let add_completion = |item: &&str| {
|
||||
let add_completion = |item: &str| {
|
||||
let mut completion =
|
||||
CompletionItem::new(CompletionKind::Attribute, ctx.source_range(), *item);
|
||||
CompletionItem::new(CompletionKind::Attribute, ctx.source_range(), item);
|
||||
completion.insert_text(format!(r#""{}""#, item));
|
||||
completion.kind(CompletionItemKind::Attribute);
|
||||
acc.add(completion.build());
|
||||
|
|
@ -26,11 +26,11 @@ pub(crate) fn complete_cfg(acc: &mut Completions, ctx: &CompletionContext) {
|
|||
.find(|t| matches!(t.kind(), SyntaxKind::IDENT));
|
||||
|
||||
match previous.as_ref().map(|p| p.text()) {
|
||||
Some("target_arch") => KNOWN_ARCH.iter().for_each(add_completion),
|
||||
Some("target_env") => KNOWN_ENV.iter().for_each(add_completion),
|
||||
Some("target_os") => KNOWN_OS.iter().for_each(add_completion),
|
||||
Some("target_vendor") => KNOWN_VENDOR.iter().for_each(add_completion),
|
||||
Some("target_endian") => ["little", "big"].iter().for_each(add_completion),
|
||||
Some("target_arch") => KNOWN_ARCH.iter().copied().for_each(add_completion),
|
||||
Some("target_env") => KNOWN_ENV.iter().copied().for_each(add_completion),
|
||||
Some("target_os") => KNOWN_OS.iter().copied().for_each(add_completion),
|
||||
Some("target_vendor") => KNOWN_VENDOR.iter().copied().for_each(add_completion),
|
||||
Some("target_endian") => ["little", "big"].into_iter().for_each(add_completion),
|
||||
Some(name) => {
|
||||
if let Some(krate) = ctx.krate {
|
||||
krate.potential_cfg(ctx.db).get_cfg_values(&name).iter().for_each(|s| {
|
||||
|
|
|
|||
|
|
@ -19,11 +19,10 @@ pub(crate) fn complete_unqualified_path(acc: &mut Completions, ctx: &CompletionC
|
|||
}
|
||||
});
|
||||
|
||||
std::array::IntoIter::new(["self::", "super::", "crate::"])
|
||||
.for_each(|kw| acc.add_keyword(ctx, kw));
|
||||
["self::", "super::", "crate::"].into_iter().for_each(|kw| acc.add_keyword(ctx, kw));
|
||||
return;
|
||||
}
|
||||
std::array::IntoIter::new(["self", "super", "crate"]).for_each(|kw| acc.add_keyword(ctx, kw));
|
||||
["self", "super", "crate"].into_iter().for_each(|kw| acc.add_keyword(ctx, kw));
|
||||
|
||||
match &ctx.completion_location {
|
||||
Some(ImmediateLocation::Visibility(_)) => return,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue