]> git.lizzy.rs Git - rust.git/commitdiff
Add multi file test for "Convert to named struct" assist
authorunexge <unexge@gmail.com>
Wed, 21 Apr 2021 13:20:08 +0000 (16:20 +0300)
committerunexge <unexge@gmail.com>
Wed, 21 Apr 2021 13:20:08 +0000 (16:20 +0300)
crates/ide_assists/src/handlers/convert_tuple_struct_to_named_struct.rs

index 086a44425922a73cd55d998fb92325c4abf45b50..0df96be0313247b35784e0f3366453b01f0729fa 100644 (file)
@@ -384,6 +384,39 @@ fn into_second(self) -> u64 {
         );
     }
 
+    #[test]
+    fn convert_struct_with_multi_file_references() {
+        check_assist(
+            convert_tuple_struct_to_named_struct,
+            r#"
+//- /main.rs
+struct Inner;
+struct A$0(Inner);
+
+mod foo;
+
+//- /foo.rs
+use crate::{A, Inner};
+fn f() {
+    let a = A(Inner);
+}
+"#,
+            r#"
+//- /main.rs
+struct Inner;
+struct A { field1: Inner }
+
+mod foo;
+
+//- /foo.rs
+use crate::{A, Inner};
+fn f() {
+    let a = A { field1: Inner };
+}
+"#,
+        );
+    }
+
     #[test]
     fn convert_struct_with_where_clause() {
         check_assist(