diff options
Diffstat (limited to 'crates')
-rw-r--r-- | crates/ide_assists/src/handlers/add_lifetime_to_type.rs | 5 | ||||
-rw-r--r-- | crates/ide_assists/src/handlers/add_turbo_fish.rs | 2 | ||||
-rw-r--r-- | crates/rust-analyzer/src/handlers.rs | 7 | ||||
-rw-r--r-- | crates/rust-analyzer/tests/rust-analyzer/main.rs | 8 |
4 files changed, 10 insertions, 12 deletions
diff --git a/crates/ide_assists/src/handlers/add_lifetime_to_type.rs b/crates/ide_assists/src/handlers/add_lifetime_to_type.rs index 2edf7b204..844928754 100644 --- a/crates/ide_assists/src/handlers/add_lifetime_to_type.rs +++ b/crates/ide_assists/src/handlers/add_lifetime_to_type.rs | |||
@@ -29,8 +29,7 @@ pub(crate) fn add_lifetime_to_type(acc: &mut Assists, ctx: &AssistContext) -> Op | |||
29 | let node = ctx.find_node_at_offset::<ast::Adt>()?; | 29 | let node = ctx.find_node_at_offset::<ast::Adt>()?; |
30 | let has_lifetime = node | 30 | let has_lifetime = node |
31 | .generic_param_list() | 31 | .generic_param_list() |
32 | .map(|gen_list| gen_list.lifetime_params().count() > 0) | 32 | .map_or(false, |gen_list| gen_list.lifetime_params().next().is_some()); |
33 | .unwrap_or_default(); | ||
34 | 33 | ||
35 | if has_lifetime { | 34 | if has_lifetime { |
36 | return None; | 35 | return None; |
@@ -41,7 +40,7 @@ pub(crate) fn add_lifetime_to_type(acc: &mut Assists, ctx: &AssistContext) -> Op | |||
41 | 40 | ||
42 | acc.add( | 41 | acc.add( |
43 | AssistId("add_lifetime_to_type", AssistKind::Generate), | 42 | AssistId("add_lifetime_to_type", AssistKind::Generate), |
44 | "Add lifetime`", | 43 | "Add lifetime", |
45 | target, | 44 | target, |
46 | |builder| { | 45 | |builder| { |
47 | match node.generic_param_list() { | 46 | match node.generic_param_list() { |
diff --git a/crates/ide_assists/src/handlers/add_turbo_fish.rs b/crates/ide_assists/src/handlers/add_turbo_fish.rs index 436767895..e4bb61c4e 100644 --- a/crates/ide_assists/src/handlers/add_turbo_fish.rs +++ b/crates/ide_assists/src/handlers/add_turbo_fish.rs | |||
@@ -26,7 +26,7 @@ use crate::{ | |||
26 | pub(crate) fn add_turbo_fish(acc: &mut Assists, ctx: &AssistContext) -> Option<()> { | 26 | pub(crate) fn add_turbo_fish(acc: &mut Assists, ctx: &AssistContext) -> Option<()> { |
27 | let ident = ctx.find_token_syntax_at_offset(SyntaxKind::IDENT).or_else(|| { | 27 | let ident = ctx.find_token_syntax_at_offset(SyntaxKind::IDENT).or_else(|| { |
28 | let arg_list = ctx.find_node_at_offset::<ast::ArgList>()?; | 28 | let arg_list = ctx.find_node_at_offset::<ast::ArgList>()?; |
29 | if arg_list.args().count() > 0 { | 29 | if arg_list.args().next().is_some() { |
30 | return None; | 30 | return None; |
31 | } | 31 | } |
32 | cov_mark::hit!(add_turbo_fish_after_call); | 32 | cov_mark::hit!(add_turbo_fish_after_call); |
diff --git a/crates/rust-analyzer/src/handlers.rs b/crates/rust-analyzer/src/handlers.rs index b6f484e51..880fea622 100644 --- a/crates/rust-analyzer/src/handlers.rs +++ b/crates/rust-analyzer/src/handlers.rs | |||
@@ -465,8 +465,11 @@ pub(crate) fn handle_will_rename_files( | |||
465 | source_change.file_system_edits.clear(); | 465 | source_change.file_system_edits.clear(); |
466 | // no collect here because we want to merge text edits on same file ids | 466 | // no collect here because we want to merge text edits on same file ids |
467 | source_change.extend(source_changes.map(|it| it.source_file_edits).flatten()); | 467 | source_change.extend(source_changes.map(|it| it.source_file_edits).flatten()); |
468 | let workspace_edit = to_proto::workspace_edit(&snap, source_change)?; | 468 | if source_change.source_file_edits.is_empty() { |
469 | Ok(Some(workspace_edit)) | 469 | Ok(None) |
470 | } else { | ||
471 | to_proto::workspace_edit(&snap, source_change).map(Some) | ||
472 | } | ||
470 | } | 473 | } |
471 | 474 | ||
472 | pub(crate) fn handle_goto_definition( | 475 | pub(crate) fn handle_goto_definition( |
diff --git a/crates/rust-analyzer/tests/rust-analyzer/main.rs b/crates/rust-analyzer/tests/rust-analyzer/main.rs index 7545b4a34..19516de7b 100644 --- a/crates/rust-analyzer/tests/rust-analyzer/main.rs +++ b/crates/rust-analyzer/tests/rust-analyzer/main.rs | |||
@@ -838,9 +838,7 @@ fn main() {} | |||
838 | new_uri: base_path.join("src/from_mod/foo.rs").to_str().unwrap().to_string(), | 838 | new_uri: base_path.join("src/from_mod/foo.rs").to_str().unwrap().to_string(), |
839 | }], | 839 | }], |
840 | }, | 840 | }, |
841 | json!({ | 841 | json!(null), |
842 | "documentChanges": [] | ||
843 | }), | ||
844 | ); | 842 | ); |
845 | 843 | ||
846 | //rename file from foo.rs to mod.rs | 844 | //rename file from foo.rs to mod.rs |
@@ -851,9 +849,7 @@ fn main() {} | |||
851 | new_uri: base_path.join("src/to_mod/mod.rs").to_str().unwrap().to_string(), | 849 | new_uri: base_path.join("src/to_mod/mod.rs").to_str().unwrap().to_string(), |
852 | }], | 850 | }], |
853 | }, | 851 | }, |
854 | json!({ | 852 | json!(null), |
855 | "documentChanges": [] | ||
856 | }), | ||
857 | ); | 853 | ); |
858 | 854 | ||
859 | //rename same level file | 855 | //rename same level file |