about summary refs log tree commit diff
diff options
context:
space:
mode:
authorJeroen Vannevel <jer_vannevel@outlook.com>2022-01-18 22:21:38 +0000
committerJeroen Vannevel <jer_vannevel@outlook.com>2022-01-22 12:08:32 +0000
commitf662d8bf38267bb39ac2db0891615febc9f8d2a9 (patch)
tree4d69c9a40cce753946af8dd395685cc9d032d32c
parentbaa5cd95278f36ec9c851c72d6042ed13ab3efac (diff)
downloadrust-f662d8bf38267bb39ac2db0891615febc9f8d2a9.tar.gz
rust-f662d8bf38267bb39ac2db0891615febc9f8d2a9.zip
repro
-rw-r--r--Cargo.toml2
-rw-r--r--crates/ide_assists/src/handlers/extract_function.rs27
2 files changed, 28 insertions, 1 deletions
diff --git a/Cargo.toml b/Cargo.toml
index 3f83041bec0..1b322acdc61 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -5,7 +5,7 @@ exclude = ["crates/proc_macro_test/imp"]
 [profile.dev]
 # Disabling debug info speeds up builds a bunch,
 # and we don't rely on it for debugging that much.
-debug = 0
+debug = 2
 
 [profile.dev.package]
 # These speed up local tests.
diff --git a/crates/ide_assists/src/handlers/extract_function.rs b/crates/ide_assists/src/handlers/extract_function.rs
index 59c52dcd04a..2032c605eb5 100644
--- a/crates/ide_assists/src/handlers/extract_function.rs
+++ b/crates/ide_assists/src/handlers/extract_function.rs
@@ -4397,4 +4397,31 @@ fn $0fun_name(arg: &mut Foo) {
 "#,
         );
     }
+
+    #[test]
+    fn extract_function_copies_comments() {
+        check_assist(
+            extract_function,
+            r#"
+fn func() {
+    let i = 0;
+    $0
+    // comment here!
+    let x = 0;
+    $0
+}
+"#,
+            r#"
+fn func() {
+    let i = 0;
+    fun_name();
+}
+
+fn $0fun_name() {
+    // comment here!
+    let x = 0;
+}
+"#,
+        );
+    }
 }