]> git.lizzy.rs Git - rust.git/blob - tests/rustdoc/macro-generated-macro.rs
Rollup merge of #107169 - albertlarsan68:lock-in-pre-push, r=Mark-Simulacrum
[rust.git] / tests / rustdoc / macro-generated-macro.rs
1 macro_rules! make_macro {
2     ($macro_name:ident $($matcher:tt)*) => {
3         #[macro_export]
4         macro_rules! $macro_name {
5             (<= $($matcher)* =>) => {};
6         }
7     }
8 }
9
10 // @has macro_generated_macro/macro.interpolations.html //pre 'macro_rules! interpolations {'
11 // @has - //pre '(<= type $($i:ident)::* + $e:expr =>) => { ... };'
12 make_macro!(interpolations type $($i:ident)::* + $e:expr);
13 interpolations!(<= type foo::bar + x.sort() =>);
14
15 // @has macro_generated_macro/macro.attributes.html //pre 'macro_rules! attributes {'
16 // @has - //pre '(<= #![no_std] #[cfg(feature = "alloc")] =>) => { ... };'
17 make_macro!(attributes #![no_std] #[cfg(feature = "alloc")]);
18
19 // @has macro_generated_macro/macro.groups.html //pre 'macro_rules! groups {'
20 // @has - //pre '(<= fn {} () { foo[0] } =>) => { ... };'
21 make_macro!(groups fn {}() {foo[0]});
22
23 // @snapshot macro_linebreak_pre macro_generated_macro/macro.linebreak.html //pre/text()
24 make_macro!(linebreak 0 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);
25
26 // @snapshot macro_morestuff_pre macro_generated_macro/macro.morestuff.html //pre/text()
27 make_macro!(morestuff
28     "space between most kinds of tokens": 1 $x + @ :: >>= 'static
29     "no space inside paren or bracket": (2 a) [2 a] $(2 $a:tt)*
30     "space inside curly brace": { 2 a }
31     "no space inside empty delimiters": () [] {}
32     "no space before comma or semicolon": a, (a), { a }, a; [T; 0];
33     "the three repetition specifiers": $(@)*, $(@)+, $(@)?
34     "repetition separators": $(@)|*, $(@)|+, $(@)==*, $(@)static*
35     "plus or star cannot be a repetition separator": $(@)+ * $(@)* +
36     "no space between ident and paren": let _ = f(0) + f[0] + Struct {};
37     "space between keyword and paren": return (a,) & for x in (..)
38     "some special case keywords": pub(crate), fn() -> u8, Self(0, 0)
39 );