Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/ide-assists/src/handlers/term_search.rs')
-rw-r--r--crates/ide-assists/src/handlers/term_search.rs25
1 files changed, 24 insertions, 1 deletions
diff --git a/crates/ide-assists/src/handlers/term_search.rs b/crates/ide-assists/src/handlers/term_search.rs
index 51a1a406f3..0f4a8e3aec 100644
--- a/crates/ide-assists/src/handlers/term_search.rs
+++ b/crates/ide-assists/src/handlers/term_search.rs
@@ -57,11 +57,14 @@ pub(crate) fn term_search(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<
})
.unique();
+ let macro_name = macro_call.name(ctx.sema.db);
+ let macro_name = macro_name.display(ctx.sema.db);
+
for code in paths {
acc.add_group(
&GroupLabel(String::from("Term search")),
AssistId("term_search", AssistKind::Generate),
- format!("Replace todo!() with {code}"),
+ format!("Replace {macro_name}!() with {code}"),
goal_range,
|builder| {
builder.replace(goal_range, code);
@@ -250,4 +253,24 @@ fn g() { let a = &1; let b: f32 = f(a); }"#,
fn g() { let a = &mut 1; let b: f32 = todo$0!(); }"#,
)
}
+
+ #[test]
+ fn test_tuple_simple() {
+ check_assist(
+ term_search,
+ r#"//- minicore: todo, unimplemented
+fn f() { let a = 1; let b = 0.0; let c: (i32, f64) = todo$0!(); }"#,
+ r#"fn f() { let a = 1; let b = 0.0; let c: (i32, f64) = (a, b); }"#,
+ )
+ }
+
+ #[test]
+ fn test_tuple_nested() {
+ check_assist(
+ term_search,
+ r#"//- minicore: todo, unimplemented
+fn f() { let a = 1; let b = 0.0; let c: (i32, (i32, f64)) = todo$0!(); }"#,
+ r#"fn f() { let a = 1; let b = 0.0; let c: (i32, (i32, f64)) = (a, (a, b)); }"#,
+ )
+ }
}