Skip to content

Commit 3eea41a

Browse files
Use SyntaxNode.ancestors instead of a loop
1 parent 6bbeffc commit 3eea41a

File tree

1 file changed

+1
-7
lines changed

1 file changed

+1
-7
lines changed

crates/ra_ssr/src/resolving.rs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -176,13 +176,7 @@ impl<'db> ResolutionScope<'db> {
176176

177177
/// Returns the function in which SSR was invoked, if any.
178178
pub(crate) fn current_function(&self) -> Option<SyntaxNode> {
179-
let mut node = self.node.clone();
180-
loop {
181-
if node.kind() == SyntaxKind::FN {
182-
return Some(node);
183-
}
184-
node = node.parent()?;
185-
}
179+
self.node.ancestors().find(|node| node.kind() == SyntaxKind::FN).map(|node| node.clone())
186180
}
187181

188182
fn resolve_path(&self, path: &ast::Path) -> Option<hir::PathResolution> {

0 commit comments

Comments
 (0)