Closed
Description
The following code (repository at https://github.com/Aaron1011/derive-bug):
// lib.rs
use proc_macro::TokenStream;
#[proc_macro_derive(MyDerive)]
pub fn my_derive(input: TokenStream) -> TokenStream {
println!("Derive input: {}", input);
TokenStream::new()
}
// main.rs
#[derive(derive_bug::MyDerive)]
struct Foo<#[cfg(FALSE)] T> {
#[cfg(FALSE)] field: T,
val: String,
array: [u8; {
#[cfg(FALSE)] struct Bar;
0
}]
}
fn main() {}
produces the following output:
Derive input: struct Foo < #[cfg(FALSE)] T > { val : String, array : [u8 ; { 0 }], }
Note how all #[cfg(FALSE)]
targets are stripped, except for the generic parameter T
. This seems quite inconsistent.
Tested on rustc 1.47.0-nightly (de521cbb3 2020-08-21)