From 1c77f3631133fbd383632f1c52819cc0fe66a709 Mon Sep 17 00:00:00 2001 From: Lukas Wirth Date: Fri, 11 Feb 2022 22:12:16 +0100 Subject: [PATCH] internal: Make `ascend_call_token` iterative instead of recursive --- crates/hir_expand/src/lib.rs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/crates/hir_expand/src/lib.rs b/crates/hir_expand/src/lib.rs index 80067dcc5d..136d62ef3b 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, ) -> Option> { - let (mapped, origin) = expansion.map_token_up(db, token.as_ref())?; - if origin != Origin::Call { - return None; + 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), + } } - if let Some(info) = mapped.file_id.expansion_info(db) { - return ascend_call_token(db, &info, mapped); - } - Some(mapped) + None } impl InFile {