diff options
| author | Vadim Petrochenkov <vadim.petrochenkov@gmail.com> | 2019-06-06 21:38:27 +0300 |
|---|---|---|
| committer | Vadim Petrochenkov <vadim.petrochenkov@gmail.com> | 2019-06-10 21:25:56 +0300 |
| commit | 5a6ebec0185c9fb0d1cb319b8f640c14a3c71d7d (patch) | |
| tree | 76ae3932f6d12443cea9004c45f09d61bc253eb3 /src/libsyntax | |
| parent | 97f4e700c20ccc95f4e9ed3d2c9d368cbc4be445 (diff) | |
| download | rust-5a6ebec0185c9fb0d1cb319b8f640c14a3c71d7d.tar.gz rust-5a6ebec0185c9fb0d1cb319b8f640c14a3c71d7d.zip | |
syntax: Remove `SyntaxExtension::MultiDecorator` and `MultiItemDecorator`
Diffstat (limited to 'src/libsyntax')
| -rw-r--r-- | src/libsyntax/ext/base.rs | 33 | ||||
| -rw-r--r-- | src/libsyntax/ext/expand.rs | 11 |
2 files changed, 1 insertions, 43 deletions
diff --git a/src/libsyntax/ext/base.rs b/src/libsyntax/ext/base.rs index ffc32127924..9979f5d0a0e 100644 --- a/src/libsyntax/ext/base.rs +++ b/src/libsyntax/ext/base.rs @@ -137,29 +137,6 @@ impl Annotatable { } } -// A more flexible ItemDecorator. -pub trait MultiItemDecorator { - fn expand(&self, - ecx: &mut ExtCtxt<'_>, - sp: Span, - meta_item: &ast::MetaItem, - item: &Annotatable, - push: &mut dyn FnMut(Annotatable)); -} - -impl<F> MultiItemDecorator for F - where F : Fn(&mut ExtCtxt<'_>, Span, &ast::MetaItem, &Annotatable, &mut dyn FnMut(Annotatable)) -{ - fn expand(&self, - ecx: &mut ExtCtxt<'_>, - sp: Span, - meta_item: &ast::MetaItem, - item: &Annotatable, - push: &mut dyn FnMut(Annotatable)) { - (*self)(ecx, sp, meta_item, item, push) - } -} - // `meta_item` is the annotation, and `item` is the item being modified. // FIXME Decorators should follow the same pattern too. pub trait MultiItemModifier { @@ -581,14 +558,6 @@ pub enum SyntaxExtension { /// A trivial "extension" that does nothing, only keeps the attribute and marks it as known. NonMacroAttr { mark_used: bool }, - /// A syntax extension that is attached to an item and creates new items - /// based upon it. - /// - /// `#[derive(...)]` is a `MultiItemDecorator`. - /// - /// Prefer ProcMacro or MultiModifier since they are more flexible. - MultiDecorator(Box<dyn MultiItemDecorator + sync::Sync + sync::Send>), - /// A syntax extension that is attached to an item and modifies it /// in-place. Also allows decoration, i.e., creating new items. MultiModifier(Box<dyn MultiItemModifier + sync::Sync + sync::Send>), @@ -658,7 +627,6 @@ impl SyntaxExtension { SyntaxExtension::ProcMacro { .. } => MacroKind::Bang, SyntaxExtension::NonMacroAttr { .. } | - SyntaxExtension::MultiDecorator(..) | SyntaxExtension::MultiModifier(..) | SyntaxExtension::AttrProcMacro(..) => MacroKind::Attr, @@ -688,7 +656,6 @@ impl SyntaxExtension { SyntaxExtension::ProcMacroDerive(.., edition) => edition, // Unstable legacy stuff SyntaxExtension::NonMacroAttr { .. } | - SyntaxExtension::MultiDecorator(..) | SyntaxExtension::MultiModifier(..) | SyntaxExtension::BuiltinDerive(..) => default_edition, } diff --git a/src/libsyntax/ext/expand.rs b/src/libsyntax/ext/expand.rs index 008bcaab889..715303db173 100644 --- a/src/libsyntax/ext/expand.rs +++ b/src/libsyntax/ext/expand.rs @@ -575,14 +575,6 @@ impl<'a, 'b> MacroExpander<'a, 'b> { let item = mac.expand(self.cx, attr.span, &meta, item); Some(invoc.fragment_kind.expect_from_annotatables(item)) } - MultiDecorator(ref mac) => { - let mut items = Vec::new(); - let meta = attr.parse_meta(self.cx.parse_sess) - .expect("derive meta should already have been parsed"); - mac.expand(self.cx, attr.span, &meta, &item, &mut |item| items.push(item)); - items.push(item); - Some(invoc.fragment_kind.expect_from_annotatables(items)) - } AttrProcMacro(ref mac, ..) => { self.gate_proc_macro_attr_item(attr.span, &item); let item_tok = TokenTree::token(token::Interpolated(Lrc::new(match item { @@ -791,8 +783,7 @@ impl<'a, 'b> MacroExpander<'a, 'b> { } } - MultiDecorator(..) | MultiModifier(..) | - AttrProcMacro(..) | SyntaxExtension::NonMacroAttr { .. } => { + MultiModifier(..) | AttrProcMacro(..) | SyntaxExtension::NonMacroAttr { .. } => { self.cx.span_err(path.span, &format!("`{}` can only be used in attributes", path)); self.cx.trace_macros_diag(); |
