diff options
| author | ice1000 <ice1000kotlin@foxmail.com> | 2022-08-19 01:08:59 +0000 |
|---|---|---|
| committer | ice1000 <ice1000kotlin@foxmail.com> | 2022-08-19 01:22:43 +0000 |
| commit | 5a6c51ebb8549467abeeac69bc2e12494cde5b29 (patch) | |
| tree | 2f5020d3dd7833299e35036464f54e6f6f957226 | |
| parent | b6fe46055bd9b16fd74df43cbbcb89e612a82b4d (diff) | |
| download | rust-5a6c51ebb8549467abeeac69bc2e12494cde5b29.tar.gz rust-5a6c51ebb8549467abeeac69bc2e12494cde5b29.zip | |
fix: use functional programming
| -rw-r--r-- | crates/ide-assists/src/handlers/inline_call.rs | 17 |
1 files changed, 7 insertions, 10 deletions
diff --git a/crates/ide-assists/src/handlers/inline_call.rs b/crates/ide-assists/src/handlers/inline_call.rs index c78c5eaa9f4..b5d092e39b0 100644 --- a/crates/ide-assists/src/handlers/inline_call.rs +++ b/crates/ide-assists/src/handlers/inline_call.rs @@ -13,7 +13,7 @@ use ide_db::{ use itertools::{izip, Itertools}; use syntax::{ ast::{self, edit_in_place::Indent, HasArgList, PathExpr}, - ted, AstNode, SyntaxKind, + ted, AstNode, NodeOrToken, SyntaxKind, }; use crate::{ @@ -311,15 +311,12 @@ fn inline( } else { fn_body.clone_for_update() }; - // TODO: use if-let chains - https://github.com/rust-lang/rust/pull/94927 - if let Some(i) = body.syntax().ancestors().find_map(ast::Impl::cast) { - if let Some(st) = i.self_ty() { - for tok in body.syntax().descendants_with_tokens().filter_map(|t| t.into_token()) { - if tok.kind() == SyntaxKind::SELF_TYPE_KW { - ted::replace(tok, st.syntax()); - } - } - } + if let Some(t) = body.syntax().ancestors().find_map(ast::Impl::cast).and_then(|i| i.self_ty()) { + body.syntax() + .descendants_with_tokens() + .filter_map(NodeOrToken::into_token) + .filter(|tok| tok.kind() == SyntaxKind::SELF_TYPE_KW) + .for_each(|tok| ted::replace(tok, t.syntax())); } let usages_for_locals = |local| { Definition::Local(local) |
