aboutsummaryrefslogtreecommitdiff
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
parent291d03949bbd1e8f96dcf348e184d91d57204419 (diff)
Test whether it is bang macro properly
-rw-r--r--crates/ra_hir_def/src/path/lower.rs14
-rw-r--r--crates/ra_syntax/src/ast/extensions.rs4
2 files changed, 10 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 }
diff --git a/crates/ra_syntax/src/ast/extensions.rs b/crates/ra_syntax/src/ast/extensions.rs
index f2ea5088e..d68f1029f 100644
--- a/crates/ra_syntax/src/ast/extensions.rs
+++ b/crates/ra_syntax/src/ast/extensions.rs
@@ -423,6 +423,10 @@ impl ast::MacroCall {
423 None 423 None
424 } 424 }
425 } 425 }
426
427 pub fn is_bang(&self) -> bool {
428 self.is_macro_rules().is_none()
429 }
426} 430}
427 431
428impl ast::LifetimeParam { 432impl ast::LifetimeParam {