diff options
| author | Folkert de Vries <folkert@folkertdev.nl> | 2025-07-04 23:56:16 +0200 |
|---|---|---|
| committer | Folkert de Vries <folkert@folkertdev.nl> | 2025-07-13 14:34:40 +0200 |
| commit | 3689b80b75bb400e740897ec83e64be332098c0d (patch) | |
| tree | db23b5f9d95c0f4613ae1599111c0c7c595be85a /compiler/rustc_expand/src/base.rs | |
| parent | 1b0bc594a75dfc1cdedc6c17052cf44de101e632 (diff) | |
| download | rust-3689b80b75bb400e740897ec83e64be332098c0d.tar.gz rust-3689b80b75bb400e740897ec83e64be332098c0d.zip | |
make `cfg_select` a builtin macro
Diffstat (limited to 'compiler/rustc_expand/src/base.rs')
| -rw-r--r-- | compiler/rustc_expand/src/base.rs | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/compiler/rustc_expand/src/base.rs b/compiler/rustc_expand/src/base.rs index d6d89808839..757a7e1c8e7 100644 --- a/compiler/rustc_expand/src/base.rs +++ b/compiler/rustc_expand/src/base.rs @@ -34,6 +34,7 @@ use thin_vec::ThinVec; use crate::base::ast::MetaItemInner; use crate::errors; use crate::expand::{self, AstFragment, Invocation}; +use crate::mbe::macro_rules::ParserAnyMacro; use crate::module::DirOwnership; use crate::stats::MacroStat; @@ -262,6 +263,25 @@ impl<T, U> ExpandResult<T, U> { } } +impl<'cx> MacroExpanderResult<'cx> { + /// Creates a [`MacroExpanderResult::Ready`] from a [`TokenStream`]. + /// + /// The `TokenStream` is forwarded without any expansion. + pub fn from_tts( + cx: &'cx mut ExtCtxt<'_>, + tts: TokenStream, + site_span: Span, + arm_span: Span, + macro_ident: Ident, + ) -> Self { + // Emit the SEMICOLON_IN_EXPRESSIONS_FROM_MACROS deprecation lint. + let is_local = true; + + let parser = ParserAnyMacro::from_tts(cx, tts, site_span, arm_span, is_local, macro_ident); + ExpandResult::Ready(Box::new(parser)) + } +} + pub trait MultiItemModifier { /// `meta_item` is the attribute, and `item` is the item being modified. fn expand( |
