Skip to content

Commit e535489

Browse files
bors[bot]kjeremy
andauthored
Merge #6104
6104: Minor clippy performance suggestions r=matklad a=kjeremy Co-authored-by: kjeremy <kjeremy@gmail.com>
2 parents c3bf765 + 82d6cfd commit e535489

File tree

6 files changed

+7
-7
lines changed

6 files changed

+7
-7
lines changed

crates/assists/src/handlers/add_missing_impl_members.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ fn add_missing_impl_members_inner(
146146

147147
let target = impl_def.syntax().text_range();
148148
acc.add(AssistId(assist_id, AssistKind::QuickFix), label, target, |builder| {
149-
let impl_item_list = impl_def.assoc_item_list().unwrap_or(make::assoc_item_list());
149+
let impl_item_list = impl_def.assoc_item_list().unwrap_or_else(make::assoc_item_list);
150150

151151
let n_existing_items = impl_item_list.assoc_items().count();
152152
let source_scope = ctx.sema.scope_for_def(trait_);

crates/assists/src/handlers/extract_struct_from_enum_variant.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ fn existing_struct_def(db: &RootDatabase, variant_name: &str, variant: &EnumVari
9191
.module(db)
9292
.scope(db, None)
9393
.into_iter()
94-
.any(|(name, _)| name.to_string() == variant_name.to_string())
94+
.any(|(name, _)| name.to_string() == variant_name)
9595
}
9696

9797
#[allow(dead_code)]

crates/hir/src/code_model.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ impl Crate {
145145
}
146146
}).flat_map(|t| t).next();
147147

148-
doc_url.map(|s| s.trim_matches('"').trim_end_matches("/").to_owned() + "/")
148+
doc_url.map(|s| s.trim_matches('"').trim_end_matches('/').to_owned() + "/")
149149
}
150150
}
151151

crates/ide/src/link_rewrite.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ fn rewrite_intra_doc_link(
120120

121121
/// Try to resolve path to local documentation via path-based links (i.e. `../gateway/struct.Shard.html`).
122122
fn rewrite_url_link(db: &RootDatabase, def: ModuleDef, target: &str) -> Option<String> {
123-
if !(target.contains("#") || target.contains(".html")) {
123+
if !(target.contains('#') || target.contains(".html")) {
124124
return None;
125125
}
126126

@@ -190,7 +190,7 @@ fn strip_prefixes_suffixes(mut s: &str) -> &str {
190190
prefixes.clone().for_each(|prefix| s = s.trim_start_matches(*prefix));
191191
suffixes.clone().for_each(|suffix| s = s.trim_end_matches(*suffix));
192192
});
193-
s.trim_start_matches("@").trim()
193+
s.trim_start_matches('@').trim()
194194
}
195195

196196
static TYPES: ([&str; 7], [&str; 0]) =

crates/ssr/src/resolving.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ impl<'db> ResolutionScope<'db> {
205205

206206
/// Returns the function in which SSR was invoked, if any.
207207
pub(crate) fn current_function(&self) -> Option<SyntaxNode> {
208-
self.node.ancestors().find(|node| node.kind() == SyntaxKind::FN).map(|node| node.clone())
208+
self.node.ancestors().find(|node| node.kind() == SyntaxKind::FN)
209209
}
210210

211211
fn resolve_path(&self, path: &ast::Path) -> Option<hir::PathResolution> {

crates/syntax/src/ast/edit.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ impl ast::AssocItemList {
159159
let whitespace =
160160
last_token_before_curly.clone().into_token().and_then(ast::Whitespace::cast)?;
161161
let text = whitespace.syntax().text();
162-
let newline = text.rfind("\n")?;
162+
let newline = text.rfind('\n')?;
163163
let keep = tokens::WsBuilder::new(&text[newline..]);
164164
Some(self.replace_children(
165165
first_token_after_items..=last_token_before_curly,

0 commit comments

Comments
 (0)