Skip to content

Commit 5cc8ad0

Browse files
bors[bot]Veykril
andauthored
Merge #8119
8119: Don't return a SourceChange on WillRenameFiles when nothing gets refactored r=Veykril a=Veykril bors r+ Co-authored-by: Lukas Wirth <[email protected]>
2 parents 4d67032 + a9a7c5c commit 5cc8ad0

File tree

4 files changed

+10
-12
lines changed

4 files changed

+10
-12
lines changed

crates/ide_assists/src/handlers/add_lifetime_to_type.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,7 @@ pub(crate) fn add_lifetime_to_type(acc: &mut Assists, ctx: &AssistContext) -> Op
2929
let node = ctx.find_node_at_offset::<ast::Adt>()?;
3030
let has_lifetime = node
3131
.generic_param_list()
32-
.map(|gen_list| gen_list.lifetime_params().count() > 0)
33-
.unwrap_or_default();
32+
.map_or(false, |gen_list| gen_list.lifetime_params().next().is_some());
3433

3534
if has_lifetime {
3635
return None;
@@ -41,7 +40,7 @@ pub(crate) fn add_lifetime_to_type(acc: &mut Assists, ctx: &AssistContext) -> Op
4140

4241
acc.add(
4342
AssistId("add_lifetime_to_type", AssistKind::Generate),
44-
"Add lifetime`",
43+
"Add lifetime",
4544
target,
4645
|builder| {
4746
match node.generic_param_list() {

crates/ide_assists/src/handlers/add_turbo_fish.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ use crate::{
2626
pub(crate) fn add_turbo_fish(acc: &mut Assists, ctx: &AssistContext) -> Option<()> {
2727
let ident = ctx.find_token_syntax_at_offset(SyntaxKind::IDENT).or_else(|| {
2828
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() {
3030
return None;
3131
}
3232
cov_mark::hit!(add_turbo_fish_after_call);

crates/rust-analyzer/src/handlers.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -465,8 +465,11 @@ pub(crate) fn handle_will_rename_files(
465465
source_change.file_system_edits.clear();
466466
// no collect here because we want to merge text edits on same file ids
467467
source_change.extend(source_changes.map(|it| it.source_file_edits).flatten());
468-
let workspace_edit = to_proto::workspace_edit(&snap, source_change)?;
469-
Ok(Some(workspace_edit))
468+
if source_change.source_file_edits.is_empty() {
469+
Ok(None)
470+
} else {
471+
to_proto::workspace_edit(&snap, source_change).map(Some)
472+
}
470473
}
471474

472475
pub(crate) fn handle_goto_definition(

crates/rust-analyzer/tests/rust-analyzer/main.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -838,9 +838,7 @@ fn main() {}
838838
new_uri: base_path.join("src/from_mod/foo.rs").to_str().unwrap().to_string(),
839839
}],
840840
},
841-
json!({
842-
"documentChanges": []
843-
}),
841+
json!(null),
844842
);
845843

846844
//rename file from foo.rs to mod.rs
@@ -851,9 +849,7 @@ fn main() {}
851849
new_uri: base_path.join("src/to_mod/mod.rs").to_str().unwrap().to_string(),
852850
}],
853851
},
854-
json!({
855-
"documentChanges": []
856-
}),
852+
json!(null),
857853
);
858854

859855
//rename same level file

0 commit comments

Comments
 (0)