aboutsummaryrefslogtreecommitdiff
path: root/crates/hir/src
diff options
context:
space:
mode:
authorLukas Wirth <[email protected]>2021-06-09 14:02:11 +0100
committerLukas Wirth <[email protected]>2021-06-09 14:02:11 +0100
commit3c40b15d625df192eb17c34f15f7dbc23f5284b9 (patch)
treef3fd6dd1072a5a8bdd7145c0f1fc3258752badb2 /crates/hir/src
parent590472607c9629fdd37e3f6f33dacfdc2a3f56cc (diff)
Don't descend MacroCall TokenTree delimiters
Diffstat (limited to 'crates/hir/src')
-rw-r--r--crates/hir/src/semantics.rs12
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};
17use syntax::{ 17use 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
23use crate::{ 23use 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(&macro_call))?; 408 let file_id = sa.expand(self.db, token.with_value(&macro_call))?;