Skip to content

Commit 5a6c51e

Browse files
committed
fix: use functional programming
1 parent b6fe460 commit 5a6c51e

File tree

1 file changed

+7
-10
lines changed

1 file changed

+7
-10
lines changed

crates/ide-assists/src/handlers/inline_call.rs

+7-10
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use ide_db::{
1313
use itertools::{izip, Itertools};
1414
use syntax::{
1515
ast::{self, edit_in_place::Indent, HasArgList, PathExpr},
16-
ted, AstNode, SyntaxKind,
16+
ted, AstNode, NodeOrToken, SyntaxKind,
1717
};
1818

1919
use crate::{
@@ -311,15 +311,12 @@ fn inline(
311311
} else {
312312
fn_body.clone_for_update()
313313
};
314-
// TODO: use if-let chains - https://github.com/rust-lang/rust/pull/94927
315-
if let Some(i) = body.syntax().ancestors().find_map(ast::Impl::cast) {
316-
if let Some(st) = i.self_ty() {
317-
for tok in body.syntax().descendants_with_tokens().filter_map(|t| t.into_token()) {
318-
if tok.kind() == SyntaxKind::SELF_TYPE_KW {
319-
ted::replace(tok, st.syntax());
320-
}
321-
}
322-
}
314+
if let Some(t) = body.syntax().ancestors().find_map(ast::Impl::cast).and_then(|i| i.self_ty()) {
315+
body.syntax()
316+
.descendants_with_tokens()
317+
.filter_map(NodeOrToken::into_token)
318+
.filter(|tok| tok.kind() == SyntaxKind::SELF_TYPE_KW)
319+
.for_each(|tok| ted::replace(tok, t.syntax()));
323320
}
324321
let usages_for_locals = |local| {
325322
Definition::Local(local)

0 commit comments

Comments
 (0)