Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions tests/ui/proc-macro/derive-cfg-nested-tokens.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// A regression test for issue #81099.

//@ check-pass
//@ proc-macro:test-macros.rs

#![feature(stmt_expr_attributes)]
#![feature(proc_macro_hygiene)]

#[macro_use]
extern crate test_macros;

#[derive(Clone, Copy)]
struct S {
// `print_args` runs twice
// - on eagerly configured `S` (from `impl Copy`), only 11 should be printed
// - on non-configured `S` (from `struct S`), both 10 and 11 should be printed
field: [u8; #[print_attr] {
#[cfg(FALSE)] { 10 }
#[cfg(not(FALSE))] { 11 }
}],
}

fn main() {}
149 changes: 149 additions & 0 deletions tests/ui/proc-macro/derive-cfg-nested-tokens.stdout
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
PRINT-ATTR INPUT (DISPLAY): { #[cfg(not(FALSE))] { 11 } }
PRINT-ATTR INPUT (DEBUG): TokenStream [
Group {
delimiter: Brace,
stream: TokenStream [
Punct {
ch: '#',
spacing: Alone,
span: #0 bytes(491..492),
},
Group {
delimiter: Bracket,
stream: TokenStream [
Ident {
ident: "cfg",
span: #0 bytes(493..496),
},
Group {
delimiter: Parenthesis,
stream: TokenStream [
Ident {
ident: "not",
span: #0 bytes(497..500),
},
Group {
delimiter: Parenthesis,
stream: TokenStream [
Ident {
ident: "FALSE",
span: #0 bytes(501..506),
},
],
span: #0 bytes(500..507),
},
],
span: #0 bytes(496..508),
},
],
span: #0 bytes(492..509),
},
Group {
delimiter: Brace,
stream: TokenStream [
Literal {
kind: Integer,
symbol: "11",
suffix: None,
span: #0 bytes(513..515),
},
],
span: #0 bytes(511..517),
},
],
span: #0 bytes(452..523),
},
]
PRINT-ATTR INPUT (DISPLAY): { #[cfg(FALSE)] { 10 } #[cfg(not(FALSE))] { 11 } }
PRINT-ATTR INPUT (DEBUG): TokenStream [
Group {
delimiter: Brace,
stream: TokenStream [
Punct {
ch: '#',
spacing: Alone,
span: #0 bytes(462..463),
},
Group {
delimiter: Bracket,
stream: TokenStream [
Ident {
ident: "cfg",
span: #0 bytes(464..467),
},
Group {
delimiter: Parenthesis,
stream: TokenStream [
Ident {
ident: "FALSE",
span: #0 bytes(468..473),
},
],
span: #0 bytes(467..474),
},
],
span: #0 bytes(463..475),
},
Group {
delimiter: Brace,
stream: TokenStream [
Literal {
kind: Integer,
symbol: "10",
suffix: None,
span: #0 bytes(478..480),
},
],
span: #0 bytes(476..482),
},
Punct {
ch: '#',
spacing: Alone,
span: #0 bytes(491..492),
},
Group {
delimiter: Bracket,
stream: TokenStream [
Ident {
ident: "cfg",
span: #0 bytes(493..496),
},
Group {
delimiter: Parenthesis,
stream: TokenStream [
Ident {
ident: "not",
span: #0 bytes(497..500),
},
Group {
delimiter: Parenthesis,
stream: TokenStream [
Ident {
ident: "FALSE",
span: #0 bytes(501..506),
},
],
span: #0 bytes(500..507),
},
],
span: #0 bytes(496..508),
},
],
span: #0 bytes(492..509),
},
Group {
delimiter: Brace,
stream: TokenStream [
Literal {
kind: Integer,
symbol: "11",
suffix: None,
span: #0 bytes(513..515),
},
],
span: #0 bytes(511..517),
},
],
span: #0 bytes(452..523),
},
]
Loading