diff options
author | Edwin Cheng <[email protected]> | 2020-05-02 03:16:26 +0100 |
---|---|---|
committer | Edwin Cheng <[email protected]> | 2020-05-02 03:16:26 +0100 |
commit | edf0b4c1528407d5077220191e601ac41f790b99 (patch) | |
tree | adc3f348325b5d1fd439f36cd31f755113331779 /crates/ra_hir_def | |
parent | 291d03949bbd1e8f96dcf348e184d91d57204419 (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.rs | 14 |
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 | }; |
12 | use ra_syntax::{ | 12 | use ra_syntax::ast::{self, AstNode, TypeAscriptionOwner, TypeBoundsOwner}; |
13 | ast::{self, AstNode, TypeAscriptionOwner, TypeBoundsOwner}, | ||
14 | T, | ||
15 | }; | ||
16 | 13 | ||
17 | use super::AssociatedTypeBinding; | 14 | use super::AssociatedTypeBinding; |
18 | use crate::{ | 15 | use 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 | } |