Minor perf tweaks per clippy

This commit is contained in:
Jeremy Kolb 2020-07-19 14:26:24 -04:00
parent 09fab42d39
commit 17f4d27f12
7 changed files with 8 additions and 8 deletions

View file

@ -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 text = token.text().as_str();
if !text.starts_with("r#") && text.ends_with("#") {
if !text.starts_with("r#") && text.ends_with('#') {
return None;
}

View file

@ -106,7 +106,7 @@ fn maybe_replace_path(
path: ast::Path,
target: ast::Path,
) -> Option<()> {
if !path_eq(path.clone(), target.clone()) {
if !path_eq(path.clone(), target) {
return None;
}

View file

@ -341,7 +341,7 @@ impl Ty {
let segment = remaining_segments.first().unwrap();
let found = associated_type_by_name_including_super_traits(
ctx.db,
trait_ref.clone(),
trait_ref,
&segment.name,
);
match found {

View file

@ -215,7 +215,7 @@ impl<'a> CompletionContext<'a> {
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 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.unsafe_is_prev = unsafe_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.is_match_arm = is_match_arm(syntax_element.clone());
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(

View file

@ -183,7 +183,7 @@ fn missing_struct_field_fix(
}
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 {
new_field = format!(",{}", new_field);
}

View file

@ -171,7 +171,7 @@ fn get_param_name_hints(
.map(|(param_name, arg)| InlayHint {
range: arg.syntax().text_range(),
kind: InlayKind::ParameterHint,
label: param_name.to_string().into(),
label: param_name.into(),
});
acc.extend(hints);

View file

@ -242,7 +242,7 @@ impl GlobalState {
})
.map(move |cargo| {
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())
})
}
}