aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir_def
diff options
context:
space:
mode:
authorEdwin Cheng <[email protected]>2020-05-02 03:16:26 +0100
committerEdwin Cheng <[email protected]>2020-05-02 03:16:26 +0100
commitedf0b4c1528407d5077220191e601ac41f790b99 (patch)
treeadc3f348325b5d1fd439f36cd31f755113331779 /crates/ra_hir_def
parent291d03949bbd1e8f96dcf348e184d91d57204419 (diff)
Test whether it is bang macro properly
Diffstat (limited to 'crates/ra_hir_def')
-rw-r--r--crates/ra_hir_def/src/path/lower.rs14
1 files changed, 6 insertions, 8 deletions
diff --git a/crates/ra_hir_def/src/path/lower.rs b/crates/ra_hir_def/src/path/lower.rs
index e632f1afb..b902cacd1 100644
--- a/crates/ra_hir_def/src/path/lower.rs
+++ b/crates/ra_hir_def/src/path/lower.rs
@@ -9,10 +9,7 @@ use hir_expand::{
9 hygiene::Hygiene, 9 hygiene::Hygiene,
10 name::{name, AsName}, 10 name::{name, AsName},
11}; 11};
12use ra_syntax::{ 12use ra_syntax::ast::{self, AstNode, TypeAscriptionOwner, TypeBoundsOwner};
13 ast::{self, AstNode, TypeAscriptionOwner, TypeBoundsOwner},
14 T,
15};
16 13
17use super::AssociatedTypeBinding; 14use super::AssociatedTypeBinding;
18use crate::{ 15use crate::{
@@ -122,10 +119,11 @@ pub(super) fn lower_path(mut path: ast::Path, hygiene: &Hygiene) -> Option<Path>
122 // https://github.com/rust-lang/rust/blob/614f273e9388ddd7804d5cbc80b8865068a3744e/src/librustc_resolve/macros.rs#L456 119 // https://github.com/rust-lang/rust/blob/614f273e9388ddd7804d5cbc80b8865068a3744e/src/librustc_resolve/macros.rs#L456
123 // We follow what it did anyway :) 120 // We follow what it did anyway :)
124 if segments.len() == 1 && kind == PathKind::Plain { 121 if segments.len() == 1 && kind == PathKind::Plain {
125 let next = path.syntax().last_token().and_then(|it| it.next_token()); 122 if let Some(macro_call) = path.syntax().parent().and_then(ast::MacroCall::cast) {
126 if next.map_or(false, |it| it.kind() == T![!]) { 123 if macro_call.is_bang() {
127 if let Some(crate_id) = hygiene.local_inner_macros() { 124 if let Some(crate_id) = hygiene.local_inner_macros() {
128 kind = PathKind::DollarCrate(crate_id); 125 kind = PathKind::DollarCrate(crate_id);
126 }
129 } 127 }
130 } 128 }
131 } 129 }