about summary refs log tree commit diff
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2022-02-11 21:21:57 +0000
committerGitHub <noreply@github.com>2022-02-11 21:21:57 +0000
commit4449a336f6965ebdfa9b7408e6ff40a6a990a43d (patch)
tree51dfda7cabc398adaaa9493e44595a6d76c21b1f
parent08348d79fa3ccb2aeeea87e758dcd5f1614c7ad8 (diff)
parent1c77f3631133fbd383632f1c52819cc0fe66a709 (diff)
Merge #11453
11453: internal: Make `ascend_call_token` iterative instead of recursive r=Veykril a=Veykril

bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
-rw-r--r--crates/hir_expand/src/lib.rs14
1 files changed, 7 insertions, 7 deletions
diff --git a/crates/hir_expand/src/lib.rs b/crates/hir_expand/src/lib.rs
index 80067dcc5d5..136d62ef3b0 100644
--- a/crates/hir_expand/src/lib.rs
+++ b/crates/hir_expand/src/lib.rs
@@ -710,14 +710,14 @@ fn ascend_call_token(
     expansion: &ExpansionInfo,
     token: InFile<SyntaxToken>,
 ) -> Option<InFile<SyntaxToken>> {
-    let (mapped, origin) = expansion.map_token_up(db, token.as_ref())?;
-    if origin != Origin::Call {
-        return None;
-    }
-    if let Some(info) = mapped.file_id.expansion_info(db) {
-        return ascend_call_token(db, &info, mapped);
+    let mut mapping = expansion.map_token_up(db, token.as_ref())?;
+    while let (mapped, Origin::Call) = mapping {
+        match mapped.file_id.expansion_info(db) {
+            Some(info) => mapping = info.map_token_up(db, mapped.as_ref())?,
+            None => return Some(mapped),
+        }
     }
-    Some(mapped)
+    None
 }
 
 impl InFile<SyntaxToken> {