aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_ssr/src/resolving.rs
diff options
context:
space:
mode:
authorDavid Lattimore <[email protected]>2020-08-05 22:36:03 +0100
committerDavid Lattimore <[email protected]>2020-08-05 22:36:03 +0100
commit3eea41a68ca2de28dca35b6e713cbb36aa09f0c8 (patch)
treec42396497d275e6113b461130218cddd89c7ef42 /crates/ra_ssr/src/resolving.rs
parent6bbeffc8c56893548f5667844f59ce5a76f9fd98 (diff)
Use SyntaxNode.ancestors instead of a loop
Diffstat (limited to 'crates/ra_ssr/src/resolving.rs')
-rw-r--r--crates/ra_ssr/src/resolving.rs8
1 files changed, 1 insertions, 7 deletions
diff --git a/crates/ra_ssr/src/resolving.rs b/crates/ra_ssr/src/resolving.rs
index 0ac929bd5..df60048eb 100644
--- a/crates/ra_ssr/src/resolving.rs
+++ b/crates/ra_ssr/src/resolving.rs
@@ -176,13 +176,7 @@ impl<'db> ResolutionScope<'db> {
176 176
177 /// Returns the function in which SSR was invoked, if any. 177 /// Returns the function in which SSR was invoked, if any.
178 pub(crate) fn current_function(&self) -> Option<SyntaxNode> { 178 pub(crate) fn current_function(&self) -> Option<SyntaxNode> {
179 let mut node = self.node.clone(); 179 self.node.ancestors().find(|node| node.kind() == SyntaxKind::FN).map(|node| node.clone())
180 loop {
181 if node.kind() == SyntaxKind::FN {
182 return Some(node);
183 }
184 node = node.parent()?;
185 }
186 } 180 }
187 181
188 fn resolve_path(&self, path: &ast::Path) -> Option<hir::PathResolution> { 182 fn resolve_path(&self, path: &ast::Path) -> Option<hir::PathResolution> {