diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2021-04-03 02:14:56 +0100 |
---|---|---|
committer | GitHub <[email protected]> | 2021-04-03 02:14:56 +0100 |
commit | bf695c487a05efecf64475ff4c34a16e90629ff1 (patch) | |
tree | b02702c17749c958434ee465530555b335abe2b8 /crates/hir_def/src/nameres | |
parent | eb264fb81963d9ec08b2797818073e8ae2993a41 (diff) | |
parent | 5742cdf3f1c591709e68d65c5701257cb77583db (diff) |
Merge #8304
8304: Support the new `panic!()` macro r=jonas-schievink a=jonas-schievink
Includes a minor fixup to macro 2.0 parsing.
bors r+
Co-authored-by: Jonas Schievink <[email protected]>
Diffstat (limited to 'crates/hir_def/src/nameres')
-rw-r--r-- | crates/hir_def/src/nameres/collector.rs | 12 |
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(), |