mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-27 05:23:24 +00:00
Minor perf tweaks per clippy
This commit is contained in:
parent
09fab42d39
commit
17f4d27f12
7 changed files with 8 additions and 8 deletions
|
@ -131,7 +131,7 @@ pub(crate) fn remove_hash(acc: &mut Assists, ctx: &AssistContext) -> Option<()>
|
||||||
let token = ctx.find_token_at_offset(RAW_STRING).and_then(ast::RawString::cast)?;
|
let token = ctx.find_token_at_offset(RAW_STRING).and_then(ast::RawString::cast)?;
|
||||||
|
|
||||||
let text = token.text().as_str();
|
let text = token.text().as_str();
|
||||||
if !text.starts_with("r#") && text.ends_with("#") {
|
if !text.starts_with("r#") && text.ends_with('#') {
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -106,7 +106,7 @@ fn maybe_replace_path(
|
||||||
path: ast::Path,
|
path: ast::Path,
|
||||||
target: ast::Path,
|
target: ast::Path,
|
||||||
) -> Option<()> {
|
) -> Option<()> {
|
||||||
if !path_eq(path.clone(), target.clone()) {
|
if !path_eq(path.clone(), target) {
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -341,7 +341,7 @@ impl Ty {
|
||||||
let segment = remaining_segments.first().unwrap();
|
let segment = remaining_segments.first().unwrap();
|
||||||
let found = associated_type_by_name_including_super_traits(
|
let found = associated_type_by_name_including_super_traits(
|
||||||
ctx.db,
|
ctx.db,
|
||||||
trait_ref.clone(),
|
trait_ref,
|
||||||
&segment.name,
|
&segment.name,
|
||||||
);
|
);
|
||||||
match found {
|
match found {
|
||||||
|
|
|
@ -215,7 +215,7 @@ impl<'a> CompletionContext<'a> {
|
||||||
|
|
||||||
fn fill_keyword_patterns(&mut self, file_with_fake_ident: &SyntaxNode, offset: TextSize) {
|
fn fill_keyword_patterns(&mut self, file_with_fake_ident: &SyntaxNode, offset: TextSize) {
|
||||||
let fake_ident_token = file_with_fake_ident.token_at_offset(offset).right_biased().unwrap();
|
let fake_ident_token = file_with_fake_ident.token_at_offset(offset).right_biased().unwrap();
|
||||||
let syntax_element = NodeOrToken::Token(fake_ident_token.clone());
|
let syntax_element = NodeOrToken::Token(fake_ident_token);
|
||||||
self.block_expr_parent = has_block_expr_parent(syntax_element.clone());
|
self.block_expr_parent = has_block_expr_parent(syntax_element.clone());
|
||||||
self.unsafe_is_prev = unsafe_is_prev(syntax_element.clone());
|
self.unsafe_is_prev = unsafe_is_prev(syntax_element.clone());
|
||||||
self.if_is_prev = if_is_prev(syntax_element.clone());
|
self.if_is_prev = if_is_prev(syntax_element.clone());
|
||||||
|
@ -228,7 +228,7 @@ impl<'a> CompletionContext<'a> {
|
||||||
self.trait_as_prev_sibling = has_trait_as_prev_sibling(syntax_element.clone());
|
self.trait_as_prev_sibling = has_trait_as_prev_sibling(syntax_element.clone());
|
||||||
self.is_match_arm = is_match_arm(syntax_element.clone());
|
self.is_match_arm = is_match_arm(syntax_element.clone());
|
||||||
self.has_item_list_or_source_file_parent =
|
self.has_item_list_or_source_file_parent =
|
||||||
has_item_list_or_source_file_parent(syntax_element.clone());
|
has_item_list_or_source_file_parent(syntax_element);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn fill(
|
fn fill(
|
||||||
|
|
|
@ -183,7 +183,7 @@ fn missing_struct_field_fix(
|
||||||
}
|
}
|
||||||
new_field = format!("\n{}{}", indent, new_field);
|
new_field = format!("\n{}{}", indent, new_field);
|
||||||
|
|
||||||
let needs_comma = !last_field_syntax.to_string().ends_with(",");
|
let needs_comma = !last_field_syntax.to_string().ends_with(',');
|
||||||
if needs_comma {
|
if needs_comma {
|
||||||
new_field = format!(",{}", new_field);
|
new_field = format!(",{}", new_field);
|
||||||
}
|
}
|
||||||
|
|
|
@ -171,7 +171,7 @@ fn get_param_name_hints(
|
||||||
.map(|(param_name, arg)| InlayHint {
|
.map(|(param_name, arg)| InlayHint {
|
||||||
range: arg.syntax().text_range(),
|
range: arg.syntax().text_range(),
|
||||||
kind: InlayKind::ParameterHint,
|
kind: InlayKind::ParameterHint,
|
||||||
label: param_name.to_string().into(),
|
label: param_name.into(),
|
||||||
});
|
});
|
||||||
|
|
||||||
acc.extend(hints);
|
acc.extend(hints);
|
||||||
|
|
|
@ -242,7 +242,7 @@ impl GlobalState {
|
||||||
})
|
})
|
||||||
.map(move |cargo| {
|
.map(move |cargo| {
|
||||||
let cargo_project_root = cargo.workspace_root().to_path_buf();
|
let cargo_project_root = cargo.workspace_root().to_path_buf();
|
||||||
FlycheckHandle::spawn(sender, config.clone(), cargo_project_root.into())
|
FlycheckHandle::spawn(sender, config, cargo_project_root.into())
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue