diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2021-06-09 14:17:38 +0100 |
---|---|---|
committer | GitHub <[email protected]> | 2021-06-09 14:17:38 +0100 |
commit | 5f592f4f58a6e1e1db0f920af34a2f569b65017c (patch) | |
tree | 00417f2fa52662fd1525b695d2d07642f9c6ba7d /crates/hir/src | |
parent | cc7cfc5d3d7777524a9e8a94da3f5f2dd455fc0a (diff) | |
parent | 3c40b15d625df192eb17c34f15f7dbc23f5284b9 (diff) |
Merge #9191
9191: fix: Don't descend MacroCall TokenTree delimiters r=jonas-schievink a=Veykril
Fixes #9190
Co-authored-by: Lukas Wirth <[email protected]>
Diffstat (limited to 'crates/hir/src')
-rw-r--r-- | crates/hir/src/semantics.rs | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/crates/hir/src/semantics.rs b/crates/hir/src/semantics.rs index 827e23e2b..d522d5245 100644 --- a/crates/hir/src/semantics.rs +++ b/crates/hir/src/semantics.rs | |||
@@ -17,7 +17,7 @@ use rustc_hash::{FxHashMap, FxHashSet}; | |||
17 | use syntax::{ | 17 | use syntax::{ |
18 | algo::find_node_at_offset, | 18 | algo::find_node_at_offset, |
19 | ast::{self, GenericParamsOwner, LoopBodyOwner}, | 19 | ast::{self, GenericParamsOwner, LoopBodyOwner}, |
20 | match_ast, AstNode, SyntaxNode, SyntaxNodePtr, SyntaxToken, TextSize, | 20 | match_ast, AstNode, SyntaxNode, SyntaxNodePtr, SyntaxToken, TextRange, TextSize, |
21 | }; | 21 | }; |
22 | 22 | ||
23 | use crate::{ | 23 | use crate::{ |
@@ -395,7 +395,15 @@ impl<'db> SemanticsImpl<'db> { | |||
395 | match node { | 395 | match node { |
396 | ast::MacroCall(macro_call) => { | 396 | ast::MacroCall(macro_call) => { |
397 | let tt = macro_call.token_tree()?; | 397 | let tt = macro_call.token_tree()?; |
398 | if !tt.syntax().text_range().contains_range(token.value.text_range()) { | 398 | let l_delim = match tt.left_delimiter_token() { |
399 | Some(it) => it.text_range().end(), | ||
400 | None => tt.syntax().text_range().start() | ||
401 | }; | ||
402 | let r_delim = match tt.right_delimiter_token() { | ||
403 | Some(it) => it.text_range().start(), | ||
404 | None => tt.syntax().text_range().end() | ||
405 | }; | ||
406 | if !TextRange::new(l_delim, r_delim).contains_range(token.value.text_range()) { | ||
399 | return None; | 407 | return None; |
400 | } | 408 | } |
401 | let file_id = sa.expand(self.db, token.with_value(¯o_call))?; | 409 | let file_id = sa.expand(self.db, token.with_value(¯o_call))?; |