aboutsummaryrefslogtreecommitdiff
path: root/crates/hir_def/src
diff options
context:
space:
mode:
authorJonas Schievink <[email protected]>2021-04-03 02:13:04 +0100
committerJonas Schievink <[email protected]>2021-04-03 02:13:04 +0100
commit5742cdf3f1c591709e68d65c5701257cb77583db (patch)
treeb02702c17749c958434ee465530555b335abe2b8 /crates/hir_def/src
parent6198eb74b2947deffa00dcd2e9e38a70f9fe6284 (diff)
Support `#[rustc_builtin_macro = "builtin_name"]`
Diffstat (limited to 'crates/hir_def/src')
-rw-r--r--crates/hir_def/src/nameres/collector.rs12
1 files changed, 11 insertions, 1 deletions
diff --git a/crates/hir_def/src/nameres/collector.rs b/crates/hir_def/src/nameres/collector.rs
index 6f946a6dd..c8f494707 100644
--- a/crates/hir_def/src/nameres/collector.rs
+++ b/crates/hir_def/src/nameres/collector.rs
@@ -1402,8 +1402,18 @@ impl ModCollector<'_, '_> {
1402 1402
1403 // Case 1: builtin macros 1403 // Case 1: builtin macros
1404 if attrs.by_key("rustc_builtin_macro").exists() { 1404 if attrs.by_key("rustc_builtin_macro").exists() {
1405 // `#[rustc_builtin_macro = "builtin_name"]` overrides the `macro_rules!` name.
1406 let name;
1407 let name = match attrs.by_key("rustc_builtin_macro").string_value() {
1408 Some(it) => {
1409 // FIXME: a hacky way to create a Name from string.
1410 name = tt::Ident { text: it.clone(), id: tt::TokenId::unspecified() }.as_name();
1411 &name
1412 }
1413 None => &mac.name,
1414 };
1405 let krate = self.def_collector.def_map.krate; 1415 let krate = self.def_collector.def_map.krate;
1406 if let Some(macro_id) = find_builtin_macro(&mac.name, krate, ast_id) { 1416 if let Some(macro_id) = find_builtin_macro(name, krate, ast_id) {
1407 self.def_collector.define_macro_rules( 1417 self.def_collector.define_macro_rules(
1408 self.module_id, 1418 self.module_id,
1409 mac.name.clone(), 1419 mac.name.clone(),