mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-11-02 04:48:13 +00:00
Merge pull request #20305 from Hmikihiro/Migrate_part_of_utils
Some checks are pending
metrics / build_metrics (push) Waiting to run
metrics / other_metrics (diesel-1.4.8) (push) Blocked by required conditions
metrics / other_metrics (hyper-0.14.18) (push) Blocked by required conditions
metrics / other_metrics (ripgrep-13.0.0) (push) Blocked by required conditions
metrics / other_metrics (self) (push) Blocked by required conditions
metrics / other_metrics (webrender-2022) (push) Blocked by required conditions
metrics / generate_final_metrics (push) Blocked by required conditions
rustdoc / rustdoc (push) Waiting to run
Some checks are pending
metrics / build_metrics (push) Waiting to run
metrics / other_metrics (diesel-1.4.8) (push) Blocked by required conditions
metrics / other_metrics (hyper-0.14.18) (push) Blocked by required conditions
metrics / other_metrics (ripgrep-13.0.0) (push) Blocked by required conditions
metrics / other_metrics (self) (push) Blocked by required conditions
metrics / other_metrics (webrender-2022) (push) Blocked by required conditions
metrics / generate_final_metrics (push) Blocked by required conditions
rustdoc / rustdoc (push) Waiting to run
Migrate part of utils.rs to use SyntaxEditor
This commit is contained in:
commit
971c393ab3
1 changed files with 5 additions and 3 deletions
|
|
@ -27,6 +27,7 @@ use syntax::{
|
|||
make,
|
||||
syntax_factory::SyntaxFactory,
|
||||
},
|
||||
syntax_editor::SyntaxEditor,
|
||||
ted,
|
||||
};
|
||||
|
||||
|
|
@ -329,7 +330,7 @@ fn invert_special_case(make: &SyntaxFactory, expr: &ast::Expr) -> Option<ast::Ex
|
|||
fn invert_special_case_legacy(expr: &ast::Expr) -> Option<ast::Expr> {
|
||||
match expr {
|
||||
ast::Expr::BinExpr(bin) => {
|
||||
let bin = bin.clone_for_update();
|
||||
let bin = bin.clone_subtree();
|
||||
let op_token = bin.op_token()?;
|
||||
let rev_token = match op_token.kind() {
|
||||
T![==] => T![!=],
|
||||
|
|
@ -345,8 +346,9 @@ fn invert_special_case_legacy(expr: &ast::Expr) -> Option<ast::Expr> {
|
|||
);
|
||||
}
|
||||
};
|
||||
ted::replace(op_token, make::token(rev_token));
|
||||
Some(bin.into())
|
||||
let mut bin_editor = SyntaxEditor::new(bin.syntax().clone());
|
||||
bin_editor.replace(op_token, make::token(rev_token));
|
||||
ast::Expr::cast(bin_editor.finish().new_root().clone())
|
||||
}
|
||||
ast::Expr::MethodCallExpr(mce) => {
|
||||
let receiver = mce.receiver()?;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue