From 8eaf17bca2674293eba0ea10056d5c77b6352086 Mon Sep 17 00:00:00 2001 From: Vadim Petrochenkov Date: Thu, 20 Jun 2019 11:52:31 +0300 Subject: Introduce built-in macros through libcore --- src/libsyntax/ext/base.rs | 6 +++++- src/libsyntax/ext/tt/macro_rules.rs | 1 + 2 files changed, 6 insertions(+), 1 deletion(-) (limited to 'src/libsyntax/ext') diff --git a/src/libsyntax/ext/base.rs b/src/libsyntax/ext/base.rs index 11b7a984aaa..0ab14bee160 100644 --- a/src/libsyntax/ext/base.rs +++ b/src/libsyntax/ext/base.rs @@ -592,6 +592,9 @@ pub struct SyntaxExtension { pub helper_attrs: Vec, /// Edition of the crate in which this macro is defined. pub edition: Edition, + /// Built-in macros have a couple of special properties (meaning of `$crate`, + /// availability in `#[no_implicit_prelude]` modules), so we have to keep this flag. + pub is_builtin: bool, } impl SyntaxExtensionKind { @@ -636,6 +639,7 @@ impl SyntaxExtension { deprecation: None, helper_attrs: Vec::new(), edition, + is_builtin: false, kind, } } @@ -687,7 +691,7 @@ pub trait Resolver { fn resolve_dollar_crates(&mut self); fn visit_ast_fragment_with_placeholders(&mut self, expn_id: ExpnId, fragment: &AstFragment, derives: &[ExpnId]); - fn add_builtin(&mut self, ident: ast::Ident, ext: Lrc); + fn register_builtin_macro(&mut self, ident: ast::Ident, ext: SyntaxExtension); fn resolve_imports(&mut self); diff --git a/src/libsyntax/ext/tt/macro_rules.rs b/src/libsyntax/ext/tt/macro_rules.rs index 4503cea0f10..c76e964b5e7 100644 --- a/src/libsyntax/ext/tt/macro_rules.rs +++ b/src/libsyntax/ext/tt/macro_rules.rs @@ -437,6 +437,7 @@ pub fn compile( deprecation: attr::find_deprecation(&sess, &def.attrs, def.span), helper_attrs: Vec::new(), edition, + is_builtin: attr::contains_name(&def.attrs, sym::rustc_builtin_macro), } } -- cgit 1.4.1-3-g733a5