Unnamed repository; edit this file 'description' to name the repository.
Merge #11453
11453: internal: Make `ascend_call_token` iterative instead of recursive r=Veykril a=Veykril bors r+ Co-authored-by: Lukas Wirth <[email protected]>
bors[bot] 2022-02-12
parent 08348d7 · parent 1c77f36 · commit 4449a33
-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 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<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> {