diff options
Diffstat (limited to 'crates/hir_expand/src/lib.rs')
-rw-r--r-- | crates/hir_expand/src/lib.rs | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/crates/hir_expand/src/lib.rs b/crates/hir_expand/src/lib.rs index 5b6734a5f..3fa1b1d77 100644 --- a/crates/hir_expand/src/lib.rs +++ b/crates/hir_expand/src/lib.rs | |||
@@ -340,8 +340,11 @@ impl ExpansionInfo { | |||
340 | Some(self.expanded.with_value(token)) | 340 | Some(self.expanded.with_value(token)) |
341 | } | 341 | } |
342 | 342 | ||
343 | pub fn map_token_up(&self, token: &SyntaxToken) -> Option<(InFile<SyntaxToken>, Origin)> { | 343 | pub fn map_token_up( |
344 | let token_id = self.exp_map.token_by_range(token.text_range())?; | 344 | &self, |
345 | token: InFile<&SyntaxToken>, | ||
346 | ) -> Option<(InFile<SyntaxToken>, Origin)> { | ||
347 | let token_id = self.exp_map.token_by_range(token.value.text_range())?; | ||
345 | 348 | ||
346 | let (token_id, origin) = self.macro_def.0.map_id_up(token_id); | 349 | let (token_id, origin) = self.macro_def.0.map_id_up(token_id); |
347 | let (token_map, tt) = match origin { | 350 | let (token_map, tt) = match origin { |
@@ -356,7 +359,7 @@ impl ExpansionInfo { | |||
356 | ), | 359 | ), |
357 | }; | 360 | }; |
358 | 361 | ||
359 | let range = token_map.range_by_token(token_id)?.by_kind(token.kind())?; | 362 | let range = token_map.range_by_token(token_id)?.by_kind(token.value.kind())?; |
360 | let token = algo::find_covering_element(&tt.value, range + tt.value.text_range().start()) | 363 | let token = algo::find_covering_element(&tt.value, range + tt.value.text_range().start()) |
361 | .into_token()?; | 364 | .into_token()?; |
362 | Some((tt.with_value(token), origin)) | 365 | Some((tt.with_value(token), origin)) |
@@ -492,7 +495,7 @@ fn ascend_call_token( | |||
492 | expansion: &ExpansionInfo, | 495 | expansion: &ExpansionInfo, |
493 | token: InFile<SyntaxToken>, | 496 | token: InFile<SyntaxToken>, |
494 | ) -> Option<InFile<SyntaxToken>> { | 497 | ) -> Option<InFile<SyntaxToken>> { |
495 | let (mapped, origin) = expansion.map_token_up(&token.value)?; | 498 | let (mapped, origin) = expansion.map_token_up(token.as_ref())?; |
496 | if origin != Origin::Call { | 499 | if origin != Origin::Call { |
497 | return None; | 500 | return None; |
498 | } | 501 | } |