Skip to content

Commit 0a4f9a2

Browse files
committed
Rebasing and making MulitDecorators work
1 parent 0a62a05 commit 0a4f9a2

File tree

4 files changed

+13
-36
lines changed

4 files changed

+13
-36
lines changed

src/librustc/plugin/registry.rs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,8 @@ use lint::{LintPassObject, LintId, Lint};
1414
use session::Session;
1515

1616
use syntax::ext::base::{SyntaxExtension, NamedSyntaxExtension, NormalTT};
17-
<<<<<<< HEAD
18-
use syntax::ext::base::{IdentTT, Decorator, Modifier, MultiModifier, MacroRulesTT};
19-
use syntax::ext::base::MacroExpanderFn;
20-
=======
21-
use syntax::ext::base::{IdentTT, Decorator, MultiDecorator, Modifier, MultiModifier, MacroRulesTT};
22-
use syntax::ext::base::{MacroExpanderFn};
23-
>>>>>>> 143f2db3174103e459218958f567985b1f47944b
17+
use syntax::ext::base::{IdentTT, Decorator, Modifier, MultiModifier, MultiDecorator};
18+
use syntax::ext::base::{MacroExpanderFn, MacroRulesTT};
2419
use syntax::codemap::Span;
2520
use syntax::parse::token;
2621
use syntax::ptr::P;

src/libsyntax/ext/base.rs

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -145,18 +145,18 @@ pub trait MultiItemDecorator {
145145
sp: Span,
146146
meta_item: &ast::MetaItem,
147147
item: &Annotatable,
148-
push: Box<FnMut(Annotatable)>);
148+
push: &mut FnMut(Annotatable));
149149
}
150150

151151
impl<F> MultiItemDecorator for F
152-
where F : Fn(&mut ExtCtxt, Span, &ast::MetaItem, &Annotatable, Box<FnMut(Annotatable)>)
152+
where F : Fn(&mut ExtCtxt, Span, &ast::MetaItem, &Annotatable, &mut FnMut(Annotatable))
153153
{
154154
fn expand(&self,
155155
ecx: &mut ExtCtxt,
156156
sp: Span,
157157
meta_item: &ast::MetaItem,
158158
item: &Annotatable,
159-
push: Box<FnMut(Annotatable)>) {
159+
push: &mut FnMut(Annotatable)) {
160160
(*self)(ecx, sp, meta_item, item, push)
161161
}
162162
}
@@ -515,13 +515,6 @@ fn initial_syntax_expander_table<'feat>(ecfg: &expand::ExpansionConfig<'feat>)
515515
syntax_expanders.insert(intern("log_syntax"),
516516
builtin_normal_expander(
517517
ext::log_syntax::expand_syntax_ext));
518-
<<<<<<< HEAD
519-
=======
520-
syntax_expanders.insert(intern("derive"),
521-
MultiDecorator(box ext::deriving::expand_meta_derive));
522-
syntax_expanders.insert(intern("deriving"),
523-
MultiDecorator(box ext::deriving::expand_deprecated_deriving));
524-
>>>>>>> 143f2db3174103e459218958f567985b1f47944b
525518

526519
ext::deriving::register_all(&mut syntax_expanders);
527520

@@ -586,11 +579,6 @@ fn initial_syntax_expander_table<'feat>(ecfg: &expand::ExpansionConfig<'feat>)
586579
syntax_expanders.insert(intern("cfg"),
587580
builtin_normal_expander(
588581
ext::cfg::expand_cfg));
589-
<<<<<<< HEAD
590-
=======
591-
syntax_expanders.insert(intern("cfg_attr"),
592-
MultiModifier(box ext::cfg_attr::expand));
593-
>>>>>>> 143f2db3174103e459218958f567985b1f47944b
594582
syntax_expanders.insert(intern("trace_macros"),
595583
builtin_normal_expander(
596584
ext::trace_macros::expand_trace_macros));

src/libsyntax/ext/deriving/mod.rs

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -80,17 +80,8 @@ pub mod generic;
8080
fn expand_derive(cx: &mut ExtCtxt,
8181
span: Span,
8282
mitem: &MetaItem,
83-
annotatable: &Annotatable)
84-
-> P<Annotatable> {
85-
// Derive can only be applied to items
86-
let item = match annotatable {
87-
&Annotatable::Item(ref it) => it.clone(),
88-
_ => {
89-
cx.span_err(span, "`derive` can only be applied to items");
90-
return;
91-
}
92-
};
93-
83+
item: P<Item>)
84+
-> P<Item> {
9485
item.map(|mut item| {
9586
if mitem.value_str().is_some() {
9687
cx.span_err(mitem.span, "unexpected value in `derive`");
@@ -123,7 +114,7 @@ fn expand_derive(cx: &mut ExtCtxt,
123114
intern_and_get_ident(&format!("derive_{}", tname)))));
124115
}
125116

126-
Annotatable::Item(item)
117+
item
127118
})
128119
}
129120

src/libsyntax/ext/expand.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1134,9 +1134,12 @@ fn expand_annotatable(a: Annotatable,
11341134
fld.cx.bt_push(ExpnInfo {
11351135
call_site: attr.span,
11361136
callee: NameAndSpan {
1137-
name: mname.get().to_string(),
1137+
name: mname.to_string(),
11381138
format: MacroAttribute,
1139-
span: None
1139+
span: Some(attr.span),
1140+
// attributes can do whatever they like,
1141+
// for now.
1142+
allow_internal_unstable: true,
11401143
}
11411144
});
11421145

0 commit comments

Comments
 (0)