- Notifications
You must be signed in to change notification settings - Fork 13.9k
Closed
Labels
A-attributesArea: Attributes (`#[…]`, `#![…]`)Area: Attributes (`#[…]`, `#![…]`)A-macrosArea: All kinds of macros (custom derive, macro_rules!, proc macros, ..)Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..)A-proc-macrosArea: Procedural macrosArea: Procedural macrosC-bugCategory: This is a bug.Category: This is a bug.
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)
Metadata
Metadata
Assignees
Labels
A-attributesArea: Attributes (`#[…]`, `#![…]`)Area: Attributes (`#[…]`, `#![…]`)A-macrosArea: All kinds of macros (custom derive, macro_rules!, proc macros, ..)Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..)A-proc-macrosArea: Procedural macrosArea: Procedural macrosC-bugCategory: This is a bug.Category: This is a bug.