Repository: rust-analyzer/rust-analyzer
Pull request #3969 (2020-04-13 20:18:41)

Change add_function assist to use todo!() instead of unimplemented!()
In the spirit of #3935


Patch:
diff --git a/crates/ra_assists/src/handlers/add_function.rs b/crates/ra_assists/src/handlers/add_function.rs
index 488bae08f1..ad4ab66ede 100644
--- a/crates/ra_assists/src/handlers/add_function.rs
+++ b/crates/ra_assists/src/handlers/add_function.rs
@@ -29,7 +29,7 @@ use rustc_hash::{FxHashMap, FxHashSet};
 // }
 //
 // fn bar(arg: &str, baz: Baz) {
-//     unimplemented!()
+//     todo!()
 // }
 //
 // ```
@@ -80,7 +80,7 @@ impl FunctionBuilder {
         Some(Self { append_fn_at, fn_name, type_params, params })
     }
     fn render(self) -> Option<FunctionTemplate> {
-        let placeholder_expr = ast::make::expr_unimplemented();
+        let placeholder_expr = ast::make::expr_todo();
         let fn_body = ast::make::block_expr(vec![], Some(placeholder_expr));
         let fn_def = ast::make::fn_def(self.fn_name, self.type_params, self.params, fn_body);
         let fn_def = ast::make::add_newlines(2, fn_def);
@@ -225,7 +225,7 @@ fn foo() {
 }
 
 fn bar() {
-    <|>unimplemented!()
+    <|>todo!()
 }
 ",
         )
@@ -252,7 +252,7 @@ impl Foo {
 }
 
 fn bar() {
-    <|>unimplemented!()
+    <|>todo!()
 }
 ",
         )
@@ -276,7 +276,7 @@ fn foo1() {
 }
 
 fn bar() {
-    <|>unimplemented!()
+    <|>todo!()
 }
 
 fn foo2() {}
@@ -302,7 +302,7 @@ mod baz {
     }
 
     fn bar() {
-        <|>unimplemented!()
+        <|>todo!()
     }
 }
 ",
@@ -315,20 +315,20 @@ mod baz {
             add_function,
             r"
 struct Baz;
-fn baz() -> Baz { unimplemented!() }
+fn baz() -> Baz { todo!() }
 fn foo() {
     bar<|>(baz());
 }
 ",
             r"
 struct Baz;
-fn baz() -> Baz { unimplemented!() }
+fn baz() -> Baz { todo!() }
 fn foo() {
     bar(baz());
 }
 
 fn bar(baz: Baz) {
-    <|>unimplemented!()
+    <|>todo!()
 }
 ",
         );
@@ -361,7 +361,7 @@ impl Baz {
 }
 
 fn bar(baz: Baz) {
-    <|>unimplemented!()
+    <|>todo!()
 }
 ",
         )
@@ -382,7 +382,7 @@ fn foo() {
 }
 
 fn bar(arg: &str) {
-    <|>unimplemented!()
+    <|>todo!()
 }
 "#,
         )
@@ -403,7 +403,7 @@ fn foo() {
 }
 
 fn bar(arg: char) {
-    <|>unimplemented!()
+    <|>todo!()
 }
 "#,
         )
@@ -424,7 +424,7 @@ fn foo() {
 }
 
 fn bar(arg: i32) {
-    <|>unimplemented!()
+    <|>todo!()
 }
 ",
         )
@@ -445,7 +445,7 @@ fn foo() {
 }
 
 fn bar(arg: u8) {
-    <|>unimplemented!()
+    <|>todo!()
 }
 ",
         )
@@ -470,7 +470,7 @@ fn foo() {
 }
 
 fn bar(x: u8) {
-    <|>unimplemented!()
+    <|>todo!()
 }
 ",
         )
@@ -493,7 +493,7 @@ fn foo() {
 }
 
 fn bar(worble: ()) {
-    <|>unimplemented!()
+    <|>todo!()
 }
 ",
         )
@@ -506,7 +506,7 @@ fn bar(worble: ()) {
             r"
 trait Foo {}
 fn foo() -> impl Foo {
-    unimplemented!()
+    todo!()
 }
 fn baz() {
     <|>bar(foo())
@@ -515,14 +515,14 @@ fn baz() {
             r"
 trait Foo {}
 fn foo() -> impl Foo {
-    unimplemented!()
+    todo!()
 }
 fn baz() {
     bar(foo())
 }
 
 fn bar(foo: impl Foo) {
-    <|>unimplemented!()
+    <|>todo!()
 }
 ",
         )
@@ -556,7 +556,7 @@ mod Foo {
     }
 
     fn bar(baz: super::Baz::Bof) {
-        <|>unimplemented!()
+        <|>todo!()
     }
 }
 ",
@@ -580,7 +580,7 @@ fn foo<T>(t: T) {
 }
 
 fn bar<T>(t: T) {
-    <|>unimplemented!()
+    <|>todo!()
 }
 ",
         )
@@ -611,7 +611,7 @@ fn foo() {
 }
 
 fn bar(arg: fn() -> Baz) {
-    <|>unimplemented!()
+    <|>todo!()
 }
 ",
         )
@@ -636,7 +636,7 @@ fn foo() {
 }
 
 fn bar(closure: impl Fn(i64) -> i64) {
-    <|>unimplemented!()
+    <|>todo!()
 }
 ",
         )
@@ -657,7 +657,7 @@ fn foo() {
 }
 
 fn bar(baz: ()) {
-    <|>unimplemented!()
+    <|>todo!()
 }
 ",
         )
@@ -682,7 +682,7 @@ fn foo() {
 }
 
 fn bar(baz_1: Baz, baz_2: Baz) {
-    <|>unimplemented!()
+    <|>todo!()
 }
 ",
         )
@@ -707,7 +707,7 @@ fn foo() {
 }
 
 fn bar(baz_1: Baz, baz_2: Baz, arg_1: &str, arg_2: &str) {
-    <|>unimplemented!()
+    <|>todo!()
 }
 "#,
         )
@@ -779,7 +779,7 @@ impl Foo {
         self.bar();
     }
     fn bar(&self) {
-        unimplemented!();
+        todo!();
     }
 }
         ",
diff --git a/docs/user/assists.md b/docs/user/assists.md
index 1d95104237..6483ba4f3e 100644
--- a/docs/user/assists.md
+++ b/docs/user/assists.md
@@ -77,7 +77,7 @@ fn foo() {
 }
 
 fn bar(arg: &str, baz: Baz) {
-    unimplemented!()
+    todo!()
 }
 
 ```


Test patch:
diff --git a/crates/ra_assists/src/doc_tests/generated.rs b/crates/ra_assists/src/doc_tests/generated.rs
index b63b4d81a2..b39e60870e 100644
--- a/crates/ra_assists/src/doc_tests/generated.rs
+++ b/crates/ra_assists/src/doc_tests/generated.rs
@@ -78,7 +78,7 @@ fn foo() {
 }
 
 fn bar(arg: &str, baz: Baz) {
-    unimplemented!()
+    todo!()
 }
 
 "#####,
diff --git a/xtask/tests/tidy-tests/main.rs b/xtask/tests/tidy-tests/main.rs
index 4f525fcd04..101ae19bd1 100644
--- a/xtask/tests/tidy-tests/main.rs
+++ b/xtask/tests/tidy-tests/main.rs
@@ -26,6 +26,7 @@ fn check_todo(path: &Path, text: &str) {
         // Some of our assists generate `todo!()` so those files are whitelisted.
         "doc_tests/generated.rs",
         "handlers/add_missing_impl_members.rs",
+        "handlers/add_function.rs",
         // To support generating `todo!()` in assists, we have `expr_todo()` in ast::make.
         "ast/make.rs",
     ];