Skip to content

Commit 4ddc9a8

Browse files
committed
---
yaml --- r: 208421 b: refs/heads/snap-stage3 c: f97cff9 h: refs/heads/master i: 208419: 3364eee v: v3
1 parent 4f1dc2d commit 4ddc9a8

File tree

3 files changed

+28
-2
lines changed

3 files changed

+28
-2
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
refs/heads/master: 38a97becdf3e6a6157f6f7ec2d98ade8d8edc193
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
4-
refs/heads/snap-stage3: 77d59217a38e2982fdcf6bff800f1c9acc0d9aaf
4+
refs/heads/snap-stage3: f97cff9abd4ea7a7a8ac24bb9afb09eb271bcda9
55
refs/heads/try: 7b4ef47b7805a402d756fb8157101f64880a522f
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d

branches/snap-stage3/src/libsyntax/ext/base.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -418,11 +418,15 @@ impl MacResult for DummyResult {
418418

419419
/// An enum representing the different kinds of syntax extensions.
420420
pub enum SyntaxExtension {
421+
/// A syntax extension that is attached to an item and creates new items
422+
/// based upon it.
423+
Decorator(Box<ItemDecorator + 'static>),
424+
421425
/// A syntax extension that is attached to an item and creates new items
422426
/// based upon it.
423427
///
424428
/// `#[derive(...)]` is an `ItemDecorator`.
425-
Decorator(Box<ItemDecorator + 'static>),
429+
MultiDecorator(Box<MultiItemDecorator + 'static>),
426430

427431
/// A syntax extension that is attached to an item and modifies it
428432
/// in-place.

branches/snap-stage3/src/libsyntax/ext/expand.rs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1096,6 +1096,28 @@ fn expand_annotatable(a: Annotatable,
10961096

10971097
fld.cx.bt_pop();
10981098
}
1099+
MultiDecorator(ref dec) => {
1100+
attr::mark_used(attr);
1101+
1102+
fld.cx.bt_push(ExpnInfo {
1103+
call_site: attr.span,
1104+
callee: NameAndSpan {
1105+
name: mname.get().to_string(),
1106+
format: MacroAttribute,
1107+
span: None
1108+
}
1109+
});
1110+
1111+
// we'd ideally decorator_items.push_all(expand_item(item, fld)),
1112+
// but that double-mut-borrows fld
1113+
let mut items: SmallVector<P<ast::Item>> = SmallVector::zero();
1114+
dec.expand(fld.cx, attr.span, &*attr.node.value, a,
1115+
box |&mut: item| items.push(item));
1116+
decorator_items.extend(items.into_iter()
1117+
.flat_map(|item| expand_item(item, fld).into_iter()));
1118+
1119+
fld.cx.bt_pop();
1120+
}
10991121
_ => new_attrs.push((*attr).clone()),
11001122
},
11011123
_ => new_attrs.push((*attr).clone()),

0 commit comments

Comments
 (0)