Skip to content

Commit 34c9cdd

Browse files
authored
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
2 parents 4114b68 + bf4911b commit 34c9cdd

File tree

3 files changed

+9
-1
lines changed

3 files changed

+9
-1
lines changed

src/libsyntax/ext/expand.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -769,7 +769,11 @@ fn expand_annotatable(mut item: Annotatable, fld: &mut MacroExpander) -> SmallVe
769769
};
770770

771771
fld.cx.bt_pop();
772-
modified.into_iter().flat_map(|it| expand_annotatable(it, fld)).collect()
772+
let configured = modified.into_iter().flat_map(|it| {
773+
it.fold_with(&mut fld.strip_unconfigured())
774+
}).collect::<SmallVector<_>>();
775+
776+
configured.into_iter().flat_map(|it| expand_annotatable(it, fld)).collect()
773777
}
774778
}
775779
}

src/test/run-pass-fulldeps/auxiliary/macro_crate_test.rs

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

src/test/run-pass-fulldeps/macro-crate.rs

+3
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ extern crate macro_crate_test;
2121
#[derive(PartialEq, Clone, Debug)]
2222
fn foo() -> AnotherFakeTypeThatHadBetterGoAway {}
2323

24+
// Check that the `#[into_multi_foo]`-generated `foo2` is configured away
25+
fn foo2() {}
26+
2427
trait Qux {
2528
#[into_multi_foo]
2629
fn bar();

0 commit comments

Comments
 (0)