diff options
-rw-r--r-- | crates/ide/src/doc_links.rs | 2 | ||||
-rw-r--r-- | crates/ide/src/goto_definition.rs | 2 | ||||
-rw-r--r-- | crates/ide/src/references/rename.rs | 6 | ||||
-rw-r--r-- | crates/ide/src/view_hir.rs | 2 | ||||
-rw-r--r-- | crates/ide_db/src/search.rs | 2 | ||||
-rw-r--r-- | crates/project_model/src/build_data.rs | 2 | ||||
-rw-r--r-- | crates/rust-analyzer/src/config.rs | 6 | ||||
-rw-r--r-- | crates/rust-analyzer/src/to_proto.rs | 4 |
8 files changed, 14 insertions, 12 deletions
diff --git a/crates/ide/src/doc_links.rs b/crates/ide/src/doc_links.rs index f94adec9b..7bdd3cca3 100644 --- a/crates/ide/src/doc_links.rs +++ b/crates/ide/src/doc_links.rs | |||
@@ -232,7 +232,7 @@ fn rewrite_intra_doc_link( | |||
232 | let items = t.items(db); | 232 | let items = t.items(db); |
233 | if let Some(field_or_assoc_item) = items.iter().find_map(|assoc_item| { | 233 | if let Some(field_or_assoc_item) = items.iter().find_map(|assoc_item| { |
234 | if let Some(name) = assoc_item.name(db) { | 234 | if let Some(name) = assoc_item.name(db) { |
235 | if link.to_string() == format!("{}::{}", canonical_path, name) { | 235 | if *link == format!("{}::{}", canonical_path, name) { |
236 | return Some(FieldOrAssocItem::AssocItem(*assoc_item)); | 236 | return Some(FieldOrAssocItem::AssocItem(*assoc_item)); |
237 | } | 237 | } |
238 | } | 238 | } |
diff --git a/crates/ide/src/goto_definition.rs b/crates/ide/src/goto_definition.rs index e86ae2a18..abed1969e 100644 --- a/crates/ide/src/goto_definition.rs +++ b/crates/ide/src/goto_definition.rs | |||
@@ -31,7 +31,7 @@ pub(crate) fn goto_definition( | |||
31 | let original_token = pick_best(file.token_at_offset(position.offset))?; | 31 | let original_token = pick_best(file.token_at_offset(position.offset))?; |
32 | let token = sema.descend_into_macros(original_token.clone()); | 32 | let token = sema.descend_into_macros(original_token.clone()); |
33 | let parent = token.parent(); | 33 | let parent = token.parent(); |
34 | if let Some(comment) = ast::Comment::cast(token.clone()) { | 34 | if let Some(comment) = ast::Comment::cast(token) { |
35 | let nav = def_for_doc_comment(&sema, position, &comment)?.try_to_nav(db)?; | 35 | let nav = def_for_doc_comment(&sema, position, &comment)?.try_to_nav(db)?; |
36 | return Some(RangeInfo::new(original_token.text_range(), vec![nav])); | 36 | return Some(RangeInfo::new(original_token.text_range(), vec![nav])); |
37 | } | 37 | } |
diff --git a/crates/ide/src/references/rename.rs b/crates/ide/src/references/rename.rs index 08f16b54d..a4b320227 100644 --- a/crates/ide/src/references/rename.rs +++ b/crates/ide/src/references/rename.rs | |||
@@ -342,8 +342,10 @@ fn rename_to_self(sema: &Semantics<RootDatabase>, local: hir::Local) -> RenameRe | |||
342 | 342 | ||
343 | // FIXME: reimplement this on the hir instead | 343 | // FIXME: reimplement this on the hir instead |
344 | // as of the time of this writing params in hir don't keep their names | 344 | // as of the time of this writing params in hir don't keep their names |
345 | let fn_ast = | 345 | let fn_ast = fn_def |
346 | fn_def.source(sema.db).ok_or(format_err!("Cannot rename non-param local to self"))?.value; | 346 | .source(sema.db) |
347 | .ok_or_else(|| format_err!("Cannot rename non-param local to self"))? | ||
348 | .value; | ||
347 | 349 | ||
348 | let first_param_range = fn_ast | 350 | let first_param_range = fn_ast |
349 | .param_list() | 351 | .param_list() |
diff --git a/crates/ide/src/view_hir.rs b/crates/ide/src/view_hir.rs index cfcfb7cfb..f8f3fae3d 100644 --- a/crates/ide/src/view_hir.rs +++ b/crates/ide/src/view_hir.rs | |||
@@ -11,7 +11,7 @@ use syntax::{algo::find_node_at_offset, ast, AstNode}; | |||
11 | // | VS Code | **Rust Analyzer: View Hir** | 11 | // | VS Code | **Rust Analyzer: View Hir** |
12 | // |=== | 12 | // |=== |
13 | pub(crate) fn view_hir(db: &RootDatabase, position: FilePosition) -> String { | 13 | pub(crate) fn view_hir(db: &RootDatabase, position: FilePosition) -> String { |
14 | body_hir(db, position).unwrap_or("Not inside a function body".to_string()) | 14 | body_hir(db, position).unwrap_or_else(|| "Not inside a function body".to_string()) |
15 | } | 15 | } |
16 | 16 | ||
17 | fn body_hir(db: &RootDatabase, position: FilePosition) -> Option<String> { | 17 | fn body_hir(db: &RootDatabase, position: FilePosition) -> Option<String> { |
diff --git a/crates/ide_db/src/search.rs b/crates/ide_db/src/search.rs index 38b20f2dc..22dd172f7 100644 --- a/crates/ide_db/src/search.rs +++ b/crates/ide_db/src/search.rs | |||
@@ -345,7 +345,7 @@ impl<'a> FindUsages<'a> { | |||
345 | for (file_id, search_range) in search_scope { | 345 | for (file_id, search_range) in search_scope { |
346 | let text = sema.db.file_text(file_id); | 346 | let text = sema.db.file_text(file_id); |
347 | let search_range = | 347 | let search_range = |
348 | search_range.unwrap_or(TextRange::up_to(TextSize::of(text.as_str()))); | 348 | search_range.unwrap_or_else(|| TextRange::up_to(TextSize::of(text.as_str()))); |
349 | 349 | ||
350 | let tree = Lazy::new(|| sema.parse(file_id).syntax().clone()); | 350 | let tree = Lazy::new(|| sema.parse(file_id).syntax().clone()); |
351 | 351 | ||
diff --git a/crates/project_model/src/build_data.rs b/crates/project_model/src/build_data.rs index a5c564e0a..295b5f8ef 100644 --- a/crates/project_model/src/build_data.rs +++ b/crates/project_model/src/build_data.rs | |||
@@ -61,7 +61,7 @@ pub(crate) type BuildDataMap = FxHashMap<String, BuildData>; | |||
61 | 61 | ||
62 | impl BuildDataCollector { | 62 | impl BuildDataCollector { |
63 | pub(crate) fn add_config(&mut self, workspace_root: &AbsPath, config: BuildDataConfig) { | 63 | pub(crate) fn add_config(&mut self, workspace_root: &AbsPath, config: BuildDataConfig) { |
64 | self.configs.insert(workspace_root.to_path_buf().clone(), config); | 64 | self.configs.insert(workspace_root.to_path_buf(), config); |
65 | } | 65 | } |
66 | 66 | ||
67 | pub fn collect(&mut self, progress: &dyn Fn(String)) -> Result<BuildDataResult> { | 67 | pub fn collect(&mut self, progress: &dyn Fn(String)) -> Result<BuildDataResult> { |
diff --git a/crates/rust-analyzer/src/config.rs b/crates/rust-analyzer/src/config.rs index 9c873c097..556fc2eeb 100644 --- a/crates/rust-analyzer/src/config.rs +++ b/crates/rust-analyzer/src/config.rs | |||
@@ -529,7 +529,7 @@ impl Config { | |||
529 | .data | 529 | .data |
530 | .checkOnSave_target | 530 | .checkOnSave_target |
531 | .clone() | 531 | .clone() |
532 | .or(self.data.cargo_target.clone()), | 532 | .or_else(|| self.data.cargo_target.clone()), |
533 | all_targets: self.data.checkOnSave_allTargets, | 533 | all_targets: self.data.checkOnSave_allTargets, |
534 | no_default_features: self | 534 | no_default_features: self |
535 | .data | 535 | .data |
@@ -543,7 +543,7 @@ impl Config { | |||
543 | .data | 543 | .data |
544 | .checkOnSave_features | 544 | .checkOnSave_features |
545 | .clone() | 545 | .clone() |
546 | .unwrap_or(self.data.cargo_features.clone()), | 546 | .unwrap_or_else(|| self.data.cargo_features.clone()), |
547 | extra_args: self.data.checkOnSave_extraArgs.clone(), | 547 | extra_args: self.data.checkOnSave_extraArgs.clone(), |
548 | }, | 548 | }, |
549 | }; | 549 | }; |
@@ -741,7 +741,7 @@ fn get_field<T: DeserializeOwned>( | |||
741 | fn schema(fields: &[(&'static str, &'static str, &[&str], &str)]) -> serde_json::Value { | 741 | fn schema(fields: &[(&'static str, &'static str, &[&str], &str)]) -> serde_json::Value { |
742 | for ((f1, ..), (f2, ..)) in fields.iter().zip(&fields[1..]) { | 742 | for ((f1, ..), (f2, ..)) in fields.iter().zip(&fields[1..]) { |
743 | fn key(f: &str) -> &str { | 743 | fn key(f: &str) -> &str { |
744 | f.splitn(2, "_").next().unwrap() | 744 | f.splitn(2, '_').next().unwrap() |
745 | } | 745 | } |
746 | assert!(key(f1) <= key(f2), "wrong field order: {:?} {:?}", f1, f2); | 746 | assert!(key(f1) <= key(f2), "wrong field order: {:?} {:?}", f1, f2); |
747 | } | 747 | } |
diff --git a/crates/rust-analyzer/src/to_proto.rs b/crates/rust-analyzer/src/to_proto.rs index 6aff65575..70cb7fbab 100644 --- a/crates/rust-analyzer/src/to_proto.rs +++ b/crates/rust-analyzer/src/to_proto.rs | |||
@@ -885,10 +885,10 @@ pub(crate) fn code_lens( | |||
885 | 885 | ||
886 | let id = lsp_types::TextDocumentIdentifier { uri: url.clone() }; | 886 | let id = lsp_types::TextDocumentIdentifier { uri: url.clone() }; |
887 | 887 | ||
888 | let doc_pos = lsp_types::TextDocumentPositionParams::new(id.clone(), position); | 888 | let doc_pos = lsp_types::TextDocumentPositionParams::new(id, position); |
889 | 889 | ||
890 | let goto_params = lsp_types::request::GotoImplementationParams { | 890 | let goto_params = lsp_types::request::GotoImplementationParams { |
891 | text_document_position_params: doc_pos.clone(), | 891 | text_document_position_params: doc_pos, |
892 | work_done_progress_params: Default::default(), | 892 | work_done_progress_params: Default::default(), |
893 | partial_result_params: Default::default(), | 893 | partial_result_params: Default::default(), |
894 | }; | 894 | }; |