Skip to content

Commit

Permalink
syntax: Remove SyntaxExtension::MultiDecorator and `MultiItemDecora…
Browse files Browse the repository at this point in the history
…tor`
  • Loading branch information
petrochenkov committed Jun 10, 2019
1 parent 97f4e70 commit 5a6ebec
Show file tree
Hide file tree
Showing 9 changed files with 1 addition and 410 deletions.
33 changes: 0 additions & 33 deletions src/libsyntax/ext/base.rs
Expand Up @@ -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 {
Expand Down Expand Up @@ -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>),
Expand Down Expand Up @@ -658,7 +627,6 @@ impl SyntaxExtension {
SyntaxExtension::ProcMacro { .. } =>
MacroKind::Bang,
SyntaxExtension::NonMacroAttr { .. } |
SyntaxExtension::MultiDecorator(..) |
SyntaxExtension::MultiModifier(..) |
SyntaxExtension::AttrProcMacro(..) =>
MacroKind::Attr,
Expand Down Expand Up @@ -688,7 +656,6 @@ impl SyntaxExtension {
SyntaxExtension::ProcMacroDerive(.., edition) => edition,
// Unstable legacy stuff
SyntaxExtension::NonMacroAttr { .. } |
SyntaxExtension::MultiDecorator(..) |
SyntaxExtension::MultiModifier(..) |
SyntaxExtension::BuiltinDerive(..) => default_edition,
}
Expand Down
11 changes: 1 addition & 10 deletions src/libsyntax/ext/expand.rs
Expand Up @@ -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 {
Expand Down Expand Up @@ -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();
Expand Down
71 changes: 0 additions & 71 deletions src/test/run-pass-fulldeps/auxiliary/custom-derive-partial-eq.rs

This file was deleted.

84 changes: 0 additions & 84 deletions src/test/run-pass-fulldeps/auxiliary/custom-derive-plugin-attr.rs

This file was deleted.

76 changes: 0 additions & 76 deletions src/test/run-pass-fulldeps/auxiliary/custom-derive-plugin.rs

This file was deleted.

10 changes: 0 additions & 10 deletions src/test/run-pass-fulldeps/custom-derive-partial-eq.rs

This file was deleted.

64 changes: 0 additions & 64 deletions src/test/run-pass-fulldeps/derive-totalsum-attr.rs

This file was deleted.

0 comments on commit 5a6ebec

Please sign in to comment.