Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit 0e11d50

Browse files
committed
Address review comment
1 parent 3973d1a commit 0e11d50

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,10 @@ pub(crate) fn convert_nested_function_to_closure(
6666
fn is_nested_function(function: &ast::Fn) -> bool {
6767
function
6868
.syntax()
69-
.parent()
70-
.map(|p| p.ancestors().any(|a| a.kind() == SyntaxKind::FN))
71-
.unwrap_or(false)
69+
.ancestors()
70+
.skip(1)
71+
.find_map(ast::Item::cast)
72+
.map_or(false, |it| matches!(it, ast::Item::Fn(_)))
7273
}
7374

7475
/// Returns whether the given nested function has generic parameters.

0 commit comments

Comments
 (0)