Skip to content

Commit

Permalink
Rebasing
Browse files Browse the repository at this point in the history
  • Loading branch information
nrc committed May 13, 2015
1 parent 103e52b commit c544e83
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 18 deletions.
18 changes: 5 additions & 13 deletions src/test/auxiliary/custom_derive_plugin.rs
Expand Up @@ -19,7 +19,7 @@ extern crate rustc;

use syntax::ast;
use syntax::codemap::Span;
use syntax::ext::base::{Decorator, ExtCtxt, Annotatable};
use syntax::ext::base::{MultiDecorator, ExtCtxt, Annotatable};
use syntax::ext::build::AstBuilder;
use syntax::ext::deriving::generic::{cs_fold, TraitDef, MethodDef, combine_substructure};
use syntax::ext::deriving::generic::ty::{Literal, LifetimeBounds, Path, borrowed_explicit_self};
Expand All @@ -31,14 +31,14 @@ use rustc::plugin::Registry;
pub fn plugin_registrar(reg: &mut Registry) {
reg.register_syntax_extension(
token::intern("derive_TotalSum"),
Decorator(box expand));
MultiDecorator(box expand));
}

fn expand(cx: &mut ExtCtxt,
span: Span,
mitem: &ast::MetaItem,
item: &ast::Item,
push: &mut FnMut(P<ast::Item>)) {
item: Annotatable,
push: &mut FnMut(Annotatable)) {
let trait_def = TraitDef {
span: span,
attributes: vec![],
Expand Down Expand Up @@ -70,13 +70,5 @@ fn expand(cx: &mut ExtCtxt,
],
};

trait_def.expand(cx,
mitem,
Annotatable::Item(P(item.clone())),
&mut |i| {
match i {
Annotatable::Item(i) => push(i),
_ => panic!("Not an item")
}
})
trait_def.expand(cx, mitem, &item, push)
}
10 changes: 5 additions & 5 deletions src/test/auxiliary/custom_derive_plugin_attr.rs
Expand Up @@ -20,7 +20,7 @@ extern crate rustc;
use syntax::ast;
use syntax::attr::AttrMetaMethods;
use syntax::codemap::Span;
use syntax::ext::base::{Decorator, ExtCtxt};
use syntax::ext::base::{MultiDecorator, ExtCtxt, Annotatable};
use syntax::ext::build::AstBuilder;
use syntax::ext::deriving::generic::{cs_fold, TraitDef, MethodDef, combine_substructure};
use syntax::ext::deriving::generic::{Substructure, Struct, EnumMatching};
Expand All @@ -33,14 +33,14 @@ use rustc::plugin::Registry;
pub fn plugin_registrar(reg: &mut Registry) {
reg.register_syntax_extension(
token::intern("derive_TotalSum"),
Decorator(box expand));
MultiDecorator(box expand));
}

fn expand(cx: &mut ExtCtxt,
span: Span,
mitem: &ast::MetaItem,
item: &ast::Item,
push: &mut FnMut(P<ast::Item>)) {
item: Annotatable,
push: &mut FnMut(Annotatable)) {
let trait_def = TraitDef {
span: span,
attributes: vec![],
Expand All @@ -61,7 +61,7 @@ fn expand(cx: &mut ExtCtxt,
],
};

trait_def.expand(cx, mitem, item, push)
trait_def.expand(cx, mitem, &item, push)
}

// Mostly copied from syntax::ext::deriving::hash
Expand Down

0 comments on commit c544e83

Please sign in to comment.