mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-24 12:03:31 +00:00
Use SyntaxNode.ancestors instead of a loop
This commit is contained in:
parent
6bbeffc8c5
commit
3eea41a68c
1 changed files with 1 additions and 7 deletions
|
@ -176,13 +176,7 @@ impl<'db> ResolutionScope<'db> {
|
|||
|
||||
/// Returns the function in which SSR was invoked, if any.
|
||||
pub(crate) fn current_function(&self) -> Option<SyntaxNode> {
|
||||
let mut node = self.node.clone();
|
||||
loop {
|
||||
if node.kind() == SyntaxKind::FN {
|
||||
return Some(node);
|
||||
}
|
||||
node = node.parent()?;
|
||||
}
|
||||
self.node.ancestors().find(|node| node.kind() == SyntaxKind::FN).map(|node| node.clone())
|
||||
}
|
||||
|
||||
fn resolve_path(&self, path: &ast::Path) -> Option<hir::PathResolution> {
|
||||
|
|
Loading…
Reference in a new issue