1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79
|
//@ compile-flags: --crate-type=lib
// https://github.com/rust-lang/rust/issues/113766
macro_rules! field {
($name:ident:$type:ty) => {
$name:$type
};
}
macro_rules! variant {
($name:ident) => {
$name
}
}
struct Struct {
//~^ NOTE while parsing this struct
field!(bar:u128),
//~^ NOTE macros cannot expand to struct fields
//~| ERROR unexpected token: `!`
//~| NOTE unexpected token after this
a: u32,
b: u32,
field!(recovers:()),
}
enum EnumVariant {
variant!(whoops),
//~^ NOTE macros cannot expand to enum variants
//~| ERROR unexpected token: `!`
//~| NOTE unexpected token after this
U32,
F64,
variant!(recovers),
//~^ NOTE macros cannot expand to enum variants
//~| ERROR unexpected token: `!`
//~| NOTE unexpected token after this
Data { //~ NOTE while parsing this struct
field!(x:u32),
//~^ NOTE macros cannot expand to struct fields
//~| ERROR unexpected token: `!`
//~| NOTE unexpected token after this
}
}
enum EnumVariantField {
Named { //~ NOTE while parsing this struct
field!(oopsies:()),
//~^ NOTE macros cannot expand to struct fields
//~| ERROR unexpected token: `!`
//~| unexpected token after this
field!(oopsies2:()),
},
}
union Union {
//~^ NOTE while parsing this union
A: u32,
field!(oopsies:()),
//~^ NOTE macros cannot expand to union fields
//~| ERROR unexpected token: `!`
//~| NOTE unexpected token after this
B: u32,
field!(recovers:()),
}
// https://github.com/rust-lang/rust/issues/114636
#[derive(Debug)]
pub struct Lazy {
//~^ NOTE while parsing this struct
unreachable!()
//~^ NOTE macros cannot expand to struct fields
//~| ERROR unexpected token: `!`
//~| NOTE unexpected token after this
}
fn main() {}
|