aboutsummaryrefslogtreecommitdiff
path: root/crates/ide
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2021-05-16 16:10:56 +0100
committerAleksey Kladov <[email protected]>2021-05-16 16:10:56 +0100
commit1859df37fd6e308ea4304f69baae038ec09fe424 (patch)
tree6a8235bfb9867ed912236e7ebb67af118321061e /crates/ide
parent9df0a2336829c54fbbc57ee8c8585aff345d9e47 (diff)
internal: use mutable syntax trees when filling fields
Diffstat (limited to 'crates/ide')
-rw-r--r--crates/ide/src/diagnostics.rs6
-rw-r--r--crates/ide/src/diagnostics/fixes.rs7
2 files changed, 7 insertions, 6 deletions
diff --git a/crates/ide/src/diagnostics.rs b/crates/ide/src/diagnostics.rs
index 273d8cfbb..d5fba6740 100644
--- a/crates/ide/src/diagnostics.rs
+++ b/crates/ide/src/diagnostics.rs
@@ -579,7 +579,7 @@ fn test_fn() {
579struct TestStruct { one: i32, two: i64 } 579struct TestStruct { one: i32, two: i64 }
580 580
581fn test_fn() { 581fn test_fn() {
582 let s = TestStruct { one: (), two: ()}; 582 let s = TestStruct { one: (), two: () };
583} 583}
584"#, 584"#,
585 ); 585 );
@@ -599,7 +599,7 @@ impl TestStruct {
599struct TestStruct { one: i32 } 599struct TestStruct { one: i32 }
600 600
601impl TestStruct { 601impl TestStruct {
602 fn test_fn() { let s = Self { one: ()}; } 602 fn test_fn() { let s = Self { one: () }; }
603} 603}
604"#, 604"#,
605 ); 605 );
@@ -792,7 +792,7 @@ fn main() {
792pub struct Foo { pub a: i32, pub b: i32 } 792pub struct Foo { pub a: i32, pub b: i32 }
793"#, 793"#,
794 r#" 794 r#"
795fn some(, b: ()) {} 795fn some(, b: () ) {}
796fn items() {} 796fn items() {}
797fn here() {} 797fn here() {}
798 798
diff --git a/crates/ide/src/diagnostics/fixes.rs b/crates/ide/src/diagnostics/fixes.rs
index 15821500f..695b59e27 100644
--- a/crates/ide/src/diagnostics/fixes.rs
+++ b/crates/ide/src/diagnostics/fixes.rs
@@ -100,11 +100,12 @@ impl DiagnosticWithFix for MissingFields {
100 let root = sema.db.parse_or_expand(self.file)?; 100 let root = sema.db.parse_or_expand(self.file)?;
101 let field_list_parent = self.field_list_parent.to_node(&root); 101 let field_list_parent = self.field_list_parent.to_node(&root);
102 let old_field_list = field_list_parent.record_expr_field_list()?; 102 let old_field_list = field_list_parent.record_expr_field_list()?;
103 let mut new_field_list = old_field_list.clone(); 103 let new_field_list = old_field_list.clone_for_update();
104 for f in self.missed_fields.iter() { 104 for f in self.missed_fields.iter() {
105 let field = 105 let field =
106 make::record_expr_field(make::name_ref(&f.to_string()), Some(make::expr_unit())); 106 make::record_expr_field(make::name_ref(&f.to_string()), Some(make::expr_unit()))
107 new_field_list = new_field_list.append_field(&field); 107 .clone_for_update();
108 new_field_list.add_field(field);
108 } 109 }
109 110
110 let edit = { 111 let edit = {