mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-08-31 15:47:31 +00:00
Fix a few clippy::perf warnings
This commit is contained in:
parent
cc49502ab4
commit
f9bb398cc5
8 changed files with 14 additions and 12 deletions
|
@ -232,7 +232,7 @@ fn rewrite_intra_doc_link(
|
|||
let items = t.items(db);
|
||||
if let Some(field_or_assoc_item) = items.iter().find_map(|assoc_item| {
|
||||
if let Some(name) = assoc_item.name(db) {
|
||||
if link.to_string() == format!("{}::{}", canonical_path, name) {
|
||||
if *link == format!("{}::{}", canonical_path, name) {
|
||||
return Some(FieldOrAssocItem::AssocItem(*assoc_item));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -31,7 +31,7 @@ pub(crate) fn goto_definition(
|
|||
let original_token = pick_best(file.token_at_offset(position.offset))?;
|
||||
let token = sema.descend_into_macros(original_token.clone());
|
||||
let parent = token.parent();
|
||||
if let Some(comment) = ast::Comment::cast(token.clone()) {
|
||||
if let Some(comment) = ast::Comment::cast(token) {
|
||||
let nav = def_for_doc_comment(&sema, position, &comment)?.try_to_nav(db)?;
|
||||
return Some(RangeInfo::new(original_token.text_range(), vec![nav]));
|
||||
}
|
||||
|
|
|
@ -342,8 +342,10 @@ fn rename_to_self(sema: &Semantics<RootDatabase>, local: hir::Local) -> RenameRe
|
|||
|
||||
// FIXME: reimplement this on the hir instead
|
||||
// as of the time of this writing params in hir don't keep their names
|
||||
let fn_ast =
|
||||
fn_def.source(sema.db).ok_or(format_err!("Cannot rename non-param local to self"))?.value;
|
||||
let fn_ast = fn_def
|
||||
.source(sema.db)
|
||||
.ok_or_else(|| format_err!("Cannot rename non-param local to self"))?
|
||||
.value;
|
||||
|
||||
let first_param_range = fn_ast
|
||||
.param_list()
|
||||
|
|
|
@ -11,7 +11,7 @@ use syntax::{algo::find_node_at_offset, ast, AstNode};
|
|||
// | VS Code | **Rust Analyzer: View Hir**
|
||||
// |===
|
||||
pub(crate) fn view_hir(db: &RootDatabase, position: FilePosition) -> String {
|
||||
body_hir(db, position).unwrap_or("Not inside a function body".to_string())
|
||||
body_hir(db, position).unwrap_or_else(|| "Not inside a function body".to_string())
|
||||
}
|
||||
|
||||
fn body_hir(db: &RootDatabase, position: FilePosition) -> Option<String> {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue