mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-24 12:03:31 +00:00
Minor clippy performance suggestions
This commit is contained in:
parent
7c9ae771bc
commit
82d6cfd495
6 changed files with 7 additions and 7 deletions
|
@ -146,7 +146,7 @@ fn add_missing_impl_members_inner(
|
||||||
|
|
||||||
let target = impl_def.syntax().text_range();
|
let target = impl_def.syntax().text_range();
|
||||||
acc.add(AssistId(assist_id, AssistKind::QuickFix), label, target, |builder| {
|
acc.add(AssistId(assist_id, AssistKind::QuickFix), label, target, |builder| {
|
||||||
let impl_item_list = impl_def.assoc_item_list().unwrap_or(make::assoc_item_list());
|
let impl_item_list = impl_def.assoc_item_list().unwrap_or_else(make::assoc_item_list);
|
||||||
|
|
||||||
let n_existing_items = impl_item_list.assoc_items().count();
|
let n_existing_items = impl_item_list.assoc_items().count();
|
||||||
let source_scope = ctx.sema.scope_for_def(trait_);
|
let source_scope = ctx.sema.scope_for_def(trait_);
|
||||||
|
|
|
@ -91,7 +91,7 @@ fn existing_struct_def(db: &RootDatabase, variant_name: &str, variant: &EnumVari
|
||||||
.module(db)
|
.module(db)
|
||||||
.scope(db, None)
|
.scope(db, None)
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.any(|(name, _)| name.to_string() == variant_name.to_string())
|
.any(|(name, _)| name.to_string() == variant_name)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
|
|
|
@ -145,7 +145,7 @@ impl Crate {
|
||||||
}
|
}
|
||||||
}).flat_map(|t| t).next();
|
}).flat_map(|t| t).next();
|
||||||
|
|
||||||
doc_url.map(|s| s.trim_matches('"').trim_end_matches("/").to_owned() + "/")
|
doc_url.map(|s| s.trim_matches('"').trim_end_matches('/').to_owned() + "/")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -120,7 +120,7 @@ fn rewrite_intra_doc_link(
|
||||||
|
|
||||||
/// Try to resolve path to local documentation via path-based links (i.e. `../gateway/struct.Shard.html`).
|
/// Try to resolve path to local documentation via path-based links (i.e. `../gateway/struct.Shard.html`).
|
||||||
fn rewrite_url_link(db: &RootDatabase, def: ModuleDef, target: &str) -> Option<String> {
|
fn rewrite_url_link(db: &RootDatabase, def: ModuleDef, target: &str) -> Option<String> {
|
||||||
if !(target.contains("#") || target.contains(".html")) {
|
if !(target.contains('#') || target.contains(".html")) {
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -190,7 +190,7 @@ fn strip_prefixes_suffixes(mut s: &str) -> &str {
|
||||||
prefixes.clone().for_each(|prefix| s = s.trim_start_matches(*prefix));
|
prefixes.clone().for_each(|prefix| s = s.trim_start_matches(*prefix));
|
||||||
suffixes.clone().for_each(|suffix| s = s.trim_end_matches(*suffix));
|
suffixes.clone().for_each(|suffix| s = s.trim_end_matches(*suffix));
|
||||||
});
|
});
|
||||||
s.trim_start_matches("@").trim()
|
s.trim_start_matches('@').trim()
|
||||||
}
|
}
|
||||||
|
|
||||||
static TYPES: ([&str; 7], [&str; 0]) =
|
static TYPES: ([&str; 7], [&str; 0]) =
|
||||||
|
|
|
@ -205,7 +205,7 @@ impl<'db> ResolutionScope<'db> {
|
||||||
|
|
||||||
/// Returns the function in which SSR was invoked, if any.
|
/// Returns the function in which SSR was invoked, if any.
|
||||||
pub(crate) fn current_function(&self) -> Option<SyntaxNode> {
|
pub(crate) fn current_function(&self) -> Option<SyntaxNode> {
|
||||||
self.node.ancestors().find(|node| node.kind() == SyntaxKind::FN).map(|node| node.clone())
|
self.node.ancestors().find(|node| node.kind() == SyntaxKind::FN)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn resolve_path(&self, path: &ast::Path) -> Option<hir::PathResolution> {
|
fn resolve_path(&self, path: &ast::Path) -> Option<hir::PathResolution> {
|
||||||
|
|
|
@ -159,7 +159,7 @@ impl ast::AssocItemList {
|
||||||
let whitespace =
|
let whitespace =
|
||||||
last_token_before_curly.clone().into_token().and_then(ast::Whitespace::cast)?;
|
last_token_before_curly.clone().into_token().and_then(ast::Whitespace::cast)?;
|
||||||
let text = whitespace.syntax().text();
|
let text = whitespace.syntax().text();
|
||||||
let newline = text.rfind("\n")?;
|
let newline = text.rfind('\n')?;
|
||||||
let keep = tokens::WsBuilder::new(&text[newline..]);
|
let keep = tokens::WsBuilder::new(&text[newline..]);
|
||||||
Some(self.replace_children(
|
Some(self.replace_children(
|
||||||
first_token_after_items..=last_token_before_curly,
|
first_token_after_items..=last_token_before_curly,
|
||||||
|
|
Loading…
Reference in a new issue