diff options
author | Lukas Wirth <[email protected]> | 2021-06-09 14:02:11 +0100 |
---|---|---|
committer | Lukas Wirth <[email protected]> | 2021-06-09 14:02:11 +0100 |
commit | 3c40b15d625df192eb17c34f15f7dbc23f5284b9 (patch) | |
tree | f3fd6dd1072a5a8bdd7145c0f1fc3258752badb2 /crates/hir | |
parent | 590472607c9629fdd37e3f6f33dacfdc2a3f56cc (diff) |
Don't descend MacroCall TokenTree delimiters
Diffstat (limited to 'crates/hir')
-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 2d08a7704..c437dbdc6 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::{ |
@@ -394,7 +394,15 @@ impl<'db> SemanticsImpl<'db> { | |||
394 | match node { | 394 | match node { |
395 | ast::MacroCall(macro_call) => { | 395 | ast::MacroCall(macro_call) => { |
396 | let tt = macro_call.token_tree()?; | 396 | let tt = macro_call.token_tree()?; |
397 | if !tt.syntax().text_range().contains_range(token.value.text_range()) { | 397 | let l_delim = match tt.left_delimiter_token() { |
398 | Some(it) => it.text_range().end(), | ||
399 | None => tt.syntax().text_range().start() | ||
400 | }; | ||
401 | let r_delim = match tt.right_delimiter_token() { | ||
402 | Some(it) => it.text_range().start(), | ||
403 | None => tt.syntax().text_range().end() | ||
404 | }; | ||
405 | if !TextRange::new(l_delim, r_delim).contains_range(token.value.text_range()) { | ||
398 | return None; | 406 | return None; |
399 | } | 407 | } |
400 | let file_id = sa.expand(self.db, token.with_value(¯o_call))?; | 408 | let file_id = sa.expand(self.db, token.with_value(¯o_call))?; |