Unnamed repository; edit this file 'description' to name the repository.
Address review comment
Jonas Platte 2023-03-31
parent 3973d1a · commit 0e11d50
-rw-r--r--crates/ide-assists/src/handlers/convert_nested_function_to_closure.rs7
1 files changed, 4 insertions, 3 deletions
diff --git a/crates/ide-assists/src/handlers/convert_nested_function_to_closure.rs b/crates/ide-assists/src/handlers/convert_nested_function_to_closure.rs
index 0524c27890..a9fd12922a 100644
--- a/crates/ide-assists/src/handlers/convert_nested_function_to_closure.rs
+++ b/crates/ide-assists/src/handlers/convert_nested_function_to_closure.rs
@@ -66,9 +66,10 @@ pub(crate) fn convert_nested_function_to_closure(
fn is_nested_function(function: &ast::Fn) -> bool {
function
.syntax()
- .parent()
- .map(|p| p.ancestors().any(|a| a.kind() == SyntaxKind::FN))
- .unwrap_or(false)
+ .ancestors()
+ .skip(1)
+ .find_map(ast::Item::cast)
+ .map_or(false, |it| matches!(it, ast::Item::Fn(_)))
}
/// Returns whether the given nested function has generic parameters.