Add test for MultiItemModifiers that add items
This commit is contained in:
parent
ac1a1d32f6
commit
58372af058
2 changed files with 11 additions and 8 deletions
|
|
@ -62,15 +62,16 @@ fn expand_identity(cx: &mut ExtCtxt, _span: Span, tts: &[TokenTree])
|
|||
fn expand_into_foo_multi(cx: &mut ExtCtxt,
|
||||
sp: Span,
|
||||
attr: &MetaItem,
|
||||
it: Annotatable) -> Annotatable {
|
||||
it: Annotatable) -> Vec<Annotatable> {
|
||||
match it {
|
||||
Annotatable::Item(it) => {
|
||||
Annotatable::Item(it) => vec![
|
||||
Annotatable::Item(P(Item {
|
||||
attrs: it.attrs.clone(),
|
||||
..(*quote_item!(cx, enum Foo2 { Bar2, Baz2 }).unwrap()).clone()
|
||||
}))
|
||||
}
|
||||
Annotatable::ImplItem(it) => {
|
||||
})),
|
||||
Annotatable::Item(quote_item!(cx, enum Foo3 { Bar }).unwrap()),
|
||||
],
|
||||
Annotatable::ImplItem(it) => vec![
|
||||
quote_item!(cx, impl X { fn foo(&self) -> i32 { 42 } }).unwrap().and_then(|i| {
|
||||
match i.node {
|
||||
ItemKind::Impl(_, _, _, _, _, mut items) => {
|
||||
|
|
@ -79,8 +80,8 @@ fn expand_into_foo_multi(cx: &mut ExtCtxt,
|
|||
_ => unreachable!("impl parsed to something other than impl")
|
||||
}
|
||||
})
|
||||
}
|
||||
Annotatable::TraitItem(it) => {
|
||||
],
|
||||
Annotatable::TraitItem(it) => vec![
|
||||
quote_item!(cx, trait X { fn foo(&self) -> i32 { 0 } }).unwrap().and_then(|i| {
|
||||
match i.node {
|
||||
ItemKind::Trait(_, _, _, mut items) => {
|
||||
|
|
@ -89,7 +90,7 @@ fn expand_into_foo_multi(cx: &mut ExtCtxt,
|
|||
_ => unreachable!("trait parsed to something other than trait")
|
||||
}
|
||||
})
|
||||
}
|
||||
],
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -40,6 +40,8 @@ pub fn main() {
|
|||
assert_eq!(Foo2::Bar2, Foo2::Bar2);
|
||||
test(None::<Foo2>);
|
||||
|
||||
let _ = Foo3::Bar;
|
||||
|
||||
let x = 10i32;
|
||||
assert_eq!(x.foo(), 42);
|
||||
let x = 10u8;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue