Address review comment

This commit is contained in:
Jonas Platte 2023-03-31 12:20:08 +02:00
parent 3973d1aaa7
commit 0e11d507e1
No known key found for this signature in database
GPG Key ID: AAA7A61F696C3E0C

View File

@ -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.