File tree Expand file tree Collapse file tree 2 files changed +9
-4
lines changed
Expand file tree Collapse file tree 2 files changed +9
-4
lines changed Original file line number Diff line number Diff line change @@ -92,10 +92,9 @@ fn replace<T: AstNode + PartialEq>(
9292 fields : impl Iterator < Item = T > ,
9393 sorted_fields : impl IntoIterator < Item = T > ,
9494) {
95- fields. zip ( sorted_fields) . for_each ( |( field, sorted_field) | {
96- // FIXME: remove `clone_for_update` when `SyntaxEditor` handles it for us
97- editor. replace ( field. syntax ( ) , sorted_field. syntax ( ) . clone_for_update ( ) )
98- } ) ;
95+ fields
96+ . zip ( sorted_fields)
97+ . for_each ( |( field, sorted_field) | editor. replace ( field. syntax ( ) , sorted_field. syntax ( ) ) ) ;
9998}
10099
101100fn compute_fields_ranks (
Original file line number Diff line number Diff line change @@ -154,6 +154,12 @@ pub(super) fn apply_edits(editor: SyntaxEditor) -> SyntaxEdit {
154154 }
155155 } ;
156156 }
157+ Change :: Replace ( SyntaxElement :: Node ( target) , Some ( SyntaxElement :: Node ( new_target) ) ) => {
158+ * target = tree_mutator. make_syntax_mut ( target) ;
159+ if new_target. ancestors ( ) . any ( |node| node == tree_mutator. immutable ) {
160+ * new_target = new_target. clone_for_update ( ) ;
161+ }
162+ }
157163 Change :: Replace ( target, _) | Change :: ReplaceWithMany ( target, _) => {
158164 * target = tree_mutator. make_element_mut ( target) ;
159165 }
You can’t perform that action at this time.
0 commit comments