Auto merge of #34654 - jseyfried:configure_multi_modified, r=nrc

Perform `cfg` attribute processing on `MultiModifier`-generated items

Fixes https://users.rust-lang.org/t/unused-attribute-warning-for-custom-derive-attribute/6180.
r? @nrc
This commit is contained in:
bors 2016-07-06 11:13:48 -07:00 committed by GitHub
commit 34c9cddc89
3 changed files with 9 additions and 1 deletions

View file

@ -769,7 +769,11 @@ fn expand_annotatable(mut item: Annotatable, fld: &mut MacroExpander) -> SmallVe
};
fld.cx.bt_pop();
modified.into_iter().flat_map(|it| expand_annotatable(it, fld)).collect()
let configured = modified.into_iter().flat_map(|it| {
it.fold_with(&mut fld.strip_unconfigured())
}).collect::<SmallVector<_>>();
configured.into_iter().flat_map(|it| expand_annotatable(it, fld)).collect()
}
}
}

View file

@ -72,6 +72,7 @@ fn expand_into_foo_multi(cx: &mut ExtCtxt,
..(*quote_item!(cx, enum Foo2 { Bar2, Baz2 }).unwrap()).clone()
})),
Annotatable::Item(quote_item!(cx, enum Foo3 { Bar }).unwrap()),
Annotatable::Item(quote_item!(cx, #[cfg(any())] fn foo2() {}).unwrap()),
],
Annotatable::ImplItem(it) => vec![
quote_item!(cx, impl X { fn foo(&self) -> i32 { 42 } }).unwrap().and_then(|i| {

View file

@ -21,6 +21,9 @@ extern crate macro_crate_test;
#[derive(PartialEq, Clone, Debug)]
fn foo() -> AnotherFakeTypeThatHadBetterGoAway {}
// Check that the `#[into_multi_foo]`-generated `foo2` is configured away
fn foo2() {}
trait Qux {
#[into_multi_foo]
fn bar();