Reproduction:
// check-pass
// aux-build:test-macros.rs
#![feature(stmt_expr_attributes)]
#![feature(proc_macro_hygiene)]
#[macro_use]
extern crate test_macros;
#[derive(PartialEq, Eq)]
struct S {
field: [u8; #[print_attr] {
#[cfg(FALSE)] { 10 }
#[cfg(not(FALSE))] { 11 }
}],
}
fn main() {}
#[derive] will fully configure the item S and remove #[cfg(FALSE)] { 10 } before outputting the item or passing it to PartialEq and Eq.
#[print_attr] however will print tokens for both cfg cases because its input tokens are not invalidated and are stale.
Fix:
#[derive] should walk the whole input item and invalidate tokens for all nested nodes, not only for the item itself.
- Attribute macros should be ready to face input with no tokens and use
CanSynthesizeMissingTokens::Yes.
cc @Aaron1011
Reproduction:
#[derive]will fully configure the itemSand remove#[cfg(FALSE)] { 10 }before outputting the item or passing it toPartialEqandEq.#[print_attr]however will print tokens for bothcfgcases because its input tokens are not invalidated and are stale.Fix:
#[derive]should walk the whole input item and invalidate tokens for all nested nodes, not only for the item itself.CanSynthesizeMissingTokens::Yes.cc @Aaron1011