diff options
| author | Vadim Petrochenkov <vadim.petrochenkov@gmail.com> | 2019-11-22 23:06:56 +0300 |
|---|---|---|
| committer | Vadim Petrochenkov <vadim.petrochenkov@gmail.com> | 2019-11-24 12:05:10 +0300 |
| commit | f89e6c881175503fd96a21e77691955ec90b5274 (patch) | |
| tree | aa6288e74512427ed7f7548894dc013ec22cacfc /src/libsyntax_ext | |
| parent | e41ced3f8d8e2f3f377ef931458e612d5f3d1f3f (diff) | |
| download | rust-f89e6c881175503fd96a21e77691955ec90b5274.tar.gz rust-f89e6c881175503fd96a21e77691955ec90b5274.zip | |
rustc_plugin: Remove support for syntactic plugins
Diffstat (limited to 'src/libsyntax_ext')
| -rw-r--r-- | src/libsyntax_ext/lib.rs | 1 | ||||
| -rw-r--r-- | src/libsyntax_ext/plugin_macro_defs.rs | 58 |
2 files changed, 0 insertions, 59 deletions
diff --git a/src/libsyntax_ext/lib.rs b/src/libsyntax_ext/lib.rs index 07fdec05046..b9287d2fe70 100644 --- a/src/libsyntax_ext/lib.rs +++ b/src/libsyntax_ext/lib.rs @@ -38,7 +38,6 @@ mod trace_macros; mod util; pub mod cmdline_attrs; -pub mod plugin_macro_defs; pub mod proc_macro_harness; pub mod standard_library_imports; pub mod test_harness; diff --git a/src/libsyntax_ext/plugin_macro_defs.rs b/src/libsyntax_ext/plugin_macro_defs.rs deleted file mode 100644 index cee1b97af55..00000000000 --- a/src/libsyntax_ext/plugin_macro_defs.rs +++ /dev/null @@ -1,58 +0,0 @@ -//! Each macro must have a definition, so `#[plugin]` attributes -//! inject a dummy `macro_rules` item for each macro they define. - -use syntax::ast::*; -use syntax::attr; -use syntax::edition::Edition; -use syntax::ptr::P; -use syntax::source_map::respan; -use syntax::symbol::sym; -use syntax::token; -use syntax::tokenstream::*; -use syntax_expand::base::{Resolver, NamedSyntaxExtension}; -use syntax_pos::{Span, DUMMY_SP}; -use syntax_pos::hygiene::{ExpnData, ExpnKind, AstPass}; - -use std::mem; - -fn plugin_macro_def(name: Name, span: Span) -> P<Item> { - let rustc_builtin_macro = attr::mk_attr_outer( - attr::mk_word_item(Ident::new(sym::rustc_builtin_macro, span))); - - let parens: TreeAndJoint = TokenTree::Delimited( - DelimSpan::from_single(span), token::Paren, TokenStream::default() - ).into(); - let trees = vec![parens.clone(), TokenTree::token(token::FatArrow, span).into(), parens]; - - P(Item { - ident: Ident::new(name, span), - attrs: vec![rustc_builtin_macro], - id: DUMMY_NODE_ID, - kind: ItemKind::MacroDef(MacroDef { tokens: TokenStream::new(trees), legacy: true }), - vis: respan(span, VisibilityKind::Inherited), - span: span, - tokens: None, - }) -} - -pub fn inject( - krate: &mut Crate, - resolver: &mut dyn Resolver, - named_exts: Vec<NamedSyntaxExtension>, - edition: Edition, -) { - if !named_exts.is_empty() { - let mut extra_items = Vec::new(); - let span = DUMMY_SP.fresh_expansion(ExpnData::allow_unstable( - ExpnKind::AstPass(AstPass::PluginMacroDefs), DUMMY_SP, edition, - [sym::rustc_attrs][..].into(), - )); - for (name, ext) in named_exts { - resolver.register_builtin_macro(Ident::with_dummy_span(name), ext); - extra_items.push(plugin_macro_def(name, span)); - } - // The `macro_rules` items must be inserted before any other items. - mem::swap(&mut extra_items, &mut krate.module.items); - krate.module.items.append(&mut extra_items); - } -} |
