diff options
Diffstat (limited to 'crates')
-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 f9098968a..04a77d677 100644 --- a/crates/rust-analyzer/src/config.rs +++ b/crates/rust-analyzer/src/config.rs | |||
@@ -519,7 +519,7 @@ impl Config { | |||
519 | .data | 519 | .data |
520 | .checkOnSave_target | 520 | .checkOnSave_target |
521 | .clone() | 521 | .clone() |
522 | .or(self.data.cargo_target.clone()), | 522 | .or_else(|| self.data.cargo_target.clone()), |
523 | all_targets: self.data.checkOnSave_allTargets, | 523 | all_targets: self.data.checkOnSave_allTargets, |
524 | no_default_features: self | 524 | no_default_features: self |
525 | .data | 525 | .data |
@@ -533,7 +533,7 @@ impl Config { | |||
533 | .data | 533 | .data |
534 | .checkOnSave_features | 534 | .checkOnSave_features |
535 | .clone() | 535 | .clone() |
536 | .unwrap_or(self.data.cargo_features.clone()), | 536 | .unwrap_or_else(|| self.data.cargo_features.clone()), |
537 | extra_args: self.data.checkOnSave_extraArgs.clone(), | 537 | extra_args: self.data.checkOnSave_extraArgs.clone(), |
538 | }, | 538 | }, |
539 | }; | 539 | }; |
@@ -731,7 +731,7 @@ fn get_field<T: DeserializeOwned>( | |||
731 | fn schema(fields: &[(&'static str, &'static str, &[&str], &str)]) -> serde_json::Value { | 731 | fn schema(fields: &[(&'static str, &'static str, &[&str], &str)]) -> serde_json::Value { |
732 | for ((f1, ..), (f2, ..)) in fields.iter().zip(&fields[1..]) { | 732 | for ((f1, ..), (f2, ..)) in fields.iter().zip(&fields[1..]) { |
733 | fn key(f: &str) -> &str { | 733 | fn key(f: &str) -> &str { |
734 | f.splitn(2, "_").next().unwrap() | 734 | f.splitn(2, '_').next().unwrap() |
735 | } | 735 | } |
736 | assert!(key(f1) <= key(f2), "wrong field order: {:?} {:?}", f1, f2); | 736 | assert!(key(f1) <= key(f2), "wrong field order: {:?} {:?}", f1, f2); |
737 | } | 737 | } |
diff --git a/crates/rust-analyzer/src/to_proto.rs b/crates/rust-analyzer/src/to_proto.rs index 8a2b4d9bd..b0ddb603d 100644 --- a/crates/rust-analyzer/src/to_proto.rs +++ b/crates/rust-analyzer/src/to_proto.rs | |||
@@ -891,10 +891,10 @@ pub(crate) fn code_lens( | |||
891 | 891 | ||
892 | let id = lsp_types::TextDocumentIdentifier { uri: url.clone() }; | 892 | let id = lsp_types::TextDocumentIdentifier { uri: url.clone() }; |
893 | 893 | ||
894 | let doc_pos = lsp_types::TextDocumentPositionParams::new(id.clone(), position); | 894 | let doc_pos = lsp_types::TextDocumentPositionParams::new(id, position); |
895 | 895 | ||
896 | let goto_params = lsp_types::request::GotoImplementationParams { | 896 | let goto_params = lsp_types::request::GotoImplementationParams { |
897 | text_document_position_params: doc_pos.clone(), | 897 | text_document_position_params: doc_pos, |
898 | work_done_progress_params: Default::default(), | 898 | work_done_progress_params: Default::default(), |
899 | partial_result_params: Default::default(), | 899 | partial_result_params: Default::default(), |
900 | }; | 900 | }; |