aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir_def/src/path/lower.rs
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2020-05-02 11:30:49 +0100
committerGitHub <[email protected]>2020-05-02 11:30:49 +0100
commitfb8fb65131c8d3e6335efd401e4e83287be49357 (patch)
tree9b82278d8f204a012a1e115f92b252c7c6150e15 /crates/ra_hir_def/src/path/lower.rs
parent75bc0249463b72971200e482d69dad88d4e76ae3 (diff)
parentedf0b4c1528407d5077220191e601ac41f790b99 (diff)
Merge #4234
4234: Support local_inner_macros r=jonas-schievink a=edwin0cheng This PR implements `#[macro_export(local_inner_macros)]` support. Note that the rustc implementation is quite [hacky][1] too. :) [1]: https://github.com/rust-lang/rust/blob/614f273e9388ddd7804d5cbc80b8865068a3744e/src/librustc_resolve/macros.rs#L456 Co-authored-by: Edwin Cheng <[email protected]>
Diffstat (limited to 'crates/ra_hir_def/src/path/lower.rs')
-rw-r--r--crates/ra_hir_def/src/path/lower.rs15
1 files changed, 15 insertions, 0 deletions
diff --git a/crates/ra_hir_def/src/path/lower.rs b/crates/ra_hir_def/src/path/lower.rs
index e3d237a0a..6a0c019fd 100644
--- a/crates/ra_hir_def/src/path/lower.rs
+++ b/crates/ra_hir_def/src/path/lower.rs
@@ -116,6 +116,21 @@ pub(super) fn lower_path(mut path: ast::Path, hygiene: &Hygiene) -> Option<Path>
116 } 116 }
117 segments.reverse(); 117 segments.reverse();
118 generic_args.reverse(); 118 generic_args.reverse();
119
120 // handle local_inner_macros :
121 // Basically, even in rustc it is quite hacky:
122 // https://github.com/rust-lang/rust/blob/614f273e9388ddd7804d5cbc80b8865068a3744e/src/librustc_resolve/macros.rs#L456
123 // We follow what it did anyway :)
124 if segments.len() == 1 && kind == PathKind::Plain {
125 if let Some(macro_call) = path.syntax().parent().and_then(ast::MacroCall::cast) {
126 if macro_call.is_bang() {
127 if let Some(crate_id) = hygiene.local_inner_macros() {
128 kind = PathKind::DollarCrate(crate_id);
129 }
130 }
131 }
132 }
133
119 let mod_path = ModPath { kind, segments }; 134 let mod_path = ModPath { kind, segments };
120 return Some(Path { type_anchor, mod_path, generic_args }); 135 return Some(Path { type_anchor, mod_path, generic_args });
121 136