File tree Expand file tree Collapse file tree 1 file changed +5
-3
lines changed Expand file tree Collapse file tree 1 file changed +5
-3
lines changed Original file line number Diff line number Diff line change @@ -27,6 +27,7 @@ use syntax::{
27
27
make,
28
28
syntax_factory:: SyntaxFactory ,
29
29
} ,
30
+ syntax_editor:: SyntaxEditor ,
30
31
ted,
31
32
} ;
32
33
@@ -329,7 +330,7 @@ fn invert_special_case(make: &SyntaxFactory, expr: &ast::Expr) -> Option<ast::Ex
329
330
fn invert_special_case_legacy ( expr : & ast:: Expr ) -> Option < ast:: Expr > {
330
331
match expr {
331
332
ast:: Expr :: BinExpr ( bin) => {
332
- let bin = bin. clone_for_update ( ) ;
333
+ let bin = bin. clone_subtree ( ) ;
333
334
let op_token = bin. op_token ( ) ?;
334
335
let rev_token = match op_token. kind ( ) {
335
336
T ! [ ==] => T ! [ !=] ,
@@ -345,8 +346,9 @@ fn invert_special_case_legacy(expr: &ast::Expr) -> Option<ast::Expr> {
345
346
) ;
346
347
}
347
348
} ;
348
- ted:: replace ( op_token, make:: token ( rev_token) ) ;
349
- Some ( bin. into ( ) )
349
+ let mut bin_editor = SyntaxEditor :: new ( bin. syntax ( ) . clone ( ) ) ;
350
+ bin_editor. replace ( op_token, make:: token ( rev_token) ) ;
351
+ ast:: Expr :: cast ( bin_editor. finish ( ) . new_root ( ) . clone ( ) )
350
352
}
351
353
ast:: Expr :: MethodCallExpr ( mce) => {
352
354
let receiver = mce. receiver ( ) ?;
You can’t perform that action at this time.
0 commit comments