3 //{{{ issue 40569 ==============================================================
5 macro_rules! my_struct {
6 ($(#[$meta:meta])* $ident:ident) => {
7 $(#[$meta])* struct $ident;
11 my_struct!(#[derive(Debug, PartialEq)] Foo40569);
14 assert_eq!(Foo40569, Foo40569);
19 //{{{ issue 26444 ==============================================================
21 macro_rules! foo_26444 {
22 ($($beginning:ident),*; $middle:ident; $($end:ident),*) => {
23 stringify!($($beginning,)* $middle $(,$end)*)
28 assert_eq!("a, b, c, d, e", foo_26444!(a, b; c; d, e));
29 assert_eq!("f", foo_26444!(; f ;));
32 macro_rules! pat_26444 {
33 ($fname:ident $($arg:pat)* =) => {}
36 pat_26444!(foo 1 2 5...7 =);
37 pat_26444!(bar Some(ref x) Ok(ref mut y) &(w, z) =);
41 //{{{ issue 40984 ==============================================================
43 macro_rules! thread_local_40984 {
45 ($(#[$attr:meta])* $vis:vis static $name:ident: $t:ty = $init:expr; $($rest:tt)*) => {
46 thread_local_40984!($($rest)*);
48 ($(#[$attr:meta])* $vis:vis static $name:ident: $t:ty = $init:expr) => {};
56 pub static BAR: String = String::from("bar");
58 // look at these restrictions!!
59 pub(crate) static BAZ: usize = 0;
60 pub(in foo) static QUUX: usize = 0;
65 //{{{ issue 35650 ==============================================================
69 std::mem::size_of::<$ty>()
77 assert_eq!(size!(u64), 8);
78 assert_eq!(size!(5), 5);
83 //{{{ issue 27832 ==============================================================
87 ( $t:tt $j:tt ) => ();
98 ( $t:tt $u:tt ) => ();
108 //{{{ issue 39964 ==============================================================
110 macro_rules! foo_39964 {
119 //{{{ issue 34030 ==============================================================
121 macro_rules! foo_34030 {
122 ($($t:ident),* /) => {};
131 //{{{ issue 24189 ==============================================================
133 macro_rules! foo_24189 {
135 pub enum $name:ident {
136 $( #[$attr:meta] )* $var:ident
151 macro_rules! serializable {
153 $(#[$struct_meta:meta])*
154 pub struct $name:ident {
156 $(#[$field_meta:meta])*
157 $field:ident: $type_:ty
180 macro_rules! foo_24189_c {
181 ( $( > )* $x:ident ) => { };
186 let _ = Foo24189::Baz;
187 let _ = Tester { name: "".to_owned() };
192 //{{{ issue 50903 ==============================================================
194 macro_rules! foo_50903 {
195 ($($lif:lifetime ,)* #) => {};
198 foo_50903!('a, 'b, #);
204 //{{{ issue 51477 ==============================================================
206 macro_rules! foo_51477 {
207 ($lifetime:lifetime) => {
208 "last token is lifetime"
211 "last token is other"
213 ($first:tt $($rest:tt)*) => {
214 foo_51477!($($rest)*)
219 assert_eq!("last token is lifetime", foo_51477!('a));
220 assert_eq!("last token is other", foo_51477!(@));
221 assert_eq!("last token is lifetime", foo_51477!(@ {} 'a));
226 //{{{ some more tests ==========================================================
228 macro_rules! test_block {
229 (< $($b:block)* >) => {}
234 test_block!(<{1}{2}>);
236 macro_rules! test_ty {
237 ($($t:ty),* $(,)*) => {}
245 macro_rules! test_path {
246 ($($t:path),* $(,)*) => {}
252 test_path!(std::ops,);
253 test_path!(any, super, super::super::self::path, X<Y>::Z<'a, T=U>);
255 macro_rules! test_lifetime {
256 (1. $($l:lifetime)* $($b:block)*) => {};
257 (2. $($b:block)* $($l:lifetime)*) => {};
260 test_lifetime!(1. 'a 'b {} {});
261 test_lifetime!(2. {} {} 'a 'b);