diff options
| author | Mara Bos <m-ou.se@m-ou.se> | 2021-01-09 16:48:58 +0100 |
|---|---|---|
| committer | Mara Bos <m-ou.se@m-ou.se> | 2021-01-09 19:50:06 +0100 |
| commit | d651fa78cefecefa87fa3d7dc1e1389d275afb63 (patch) | |
| tree | 45bc43f0d9979d6cd5051426d24cab97102593ae /compiler/rustc_expand/src/base.rs | |
| parent | 1f9dc9a1821d55b1641c517feac7fcd6ac76aadc (diff) | |
| download | rust-d651fa78cefecefa87fa3d7dc1e1389d275afb63.tar.gz rust-d651fa78cefecefa87fa3d7dc1e1389d275afb63.zip | |
Allow #[rustc_builtin_macro = "name"].
This makes it possible to have both std::panic and core::panic as a builtin macro, by using different builtin macro names for each. Also removes SyntaxExtension::is_derive_copy, as the macro name (e.g. sym::Copy) is now tracked and provides that information directly.
Diffstat (limited to 'compiler/rustc_expand/src/base.rs')
| -rw-r--r-- | compiler/rustc_expand/src/base.rs | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/compiler/rustc_expand/src/base.rs b/compiler/rustc_expand/src/base.rs index b2ba720e0d7..897788f6f8d 100644 --- a/compiler/rustc_expand/src/base.rs +++ b/compiler/rustc_expand/src/base.rs @@ -728,9 +728,7 @@ pub struct SyntaxExtension { pub edition: Edition, /// Built-in macros have a couple of special properties like availability /// in `#[no_implicit_prelude]` modules, so we have to keep this flag. - pub is_builtin: bool, - /// We have to identify macros providing a `Copy` impl early for compatibility reasons. - pub is_derive_copy: bool, + pub builtin_name: Option<Symbol>, } impl SyntaxExtension { @@ -758,8 +756,7 @@ impl SyntaxExtension { deprecation: None, helper_attrs: Vec::new(), edition, - is_builtin: false, - is_derive_copy: false, + builtin_name: None, kind, } } @@ -785,7 +782,7 @@ impl SyntaxExtension { } } - let is_builtin = sess.contains_name(attrs, sym::rustc_builtin_macro); + let builtin_name = sess.find_by_name(attrs, sym::rustc_builtin_macro).map(|a| a.value_str().unwrap_or(name)); let (stability, const_stability) = attr::find_stability(&sess, attrs, span); if const_stability.is_some() { sess.parse_sess @@ -803,8 +800,7 @@ impl SyntaxExtension { deprecation: attr::find_deprecation(&sess, attrs).map(|(d, _)| d), helper_attrs, edition, - is_builtin, - is_derive_copy: is_builtin && name == sym::Copy, + builtin_name, } } |
