about summary refs log tree commit diff
diff options
context:
space:
mode:
authorJeroen Vannevel <jer_vannevel@outlook.com>2022-01-04 02:12:53 +0000
committerJeroen Vannevel <jer_vannevel@outlook.com>2022-01-04 02:12:53 +0000
commit5beddf93e75ab1d001fc2382830cea560b1473fd (patch)
treea2b675a70aa34012fab2653987b4a72629b8d891
parent95cabfd7227d5dc70d1ec370da3173e92447a476 (diff)
downloadrust-5beddf93e75ab1d001fc2382830cea560b1473fd.tar.gz
rust-5beddf93e75ab1d001fc2382830cea560b1473fd.zip
additional test without further usages
-rw-r--r--crates/ide_assists/src/handlers/extract_function.rs33
1 files changed, 32 insertions, 1 deletions
diff --git a/crates/ide_assists/src/handlers/extract_function.rs b/crates/ide_assists/src/handlers/extract_function.rs
index 8c7fb03f7af..2821f6cde98 100644
--- a/crates/ide_assists/src/handlers/extract_function.rs
+++ b/crates/ide_assists/src/handlers/extract_function.rs
@@ -4337,7 +4337,7 @@ fn $0fun_name(a: _) -> _ {
     }
 
     #[test]
-    fn test_jeroen() {
+    fn reference_mutable_param_with_further_usages() {
         check_assist(
             extract_function,
             r#"
@@ -4372,4 +4372,35 @@ fn $0fun_name(arg: &mut Foo) {
 "#,
         );
     }
+
+    #[test]
+    fn reference_mutable_param_without_further_usages() {
+        check_assist(
+            extract_function,
+            r#"
+pub struct Foo {
+    field: u32,
+}
+
+pub fn testfn(arg: &mut Foo) {
+    $0arg.field = 8; // write access
+    println!("{}", arg.field); // read access$0
+}
+"#,
+            r#"
+pub struct Foo {
+    field: u32,
+}
+
+pub fn testfn(arg: &mut Foo) {
+    fun_name(arg); // read access
+}
+
+fn $0fun_name(arg: &mut Foo) {
+    arg.field = 8;
+    println!("{}", arg.field);
+}
+"#,
+        );
+    }
 }