2018-02-23 08:10:17 +09:00
|
|
|
// rustfmt-error_on_line_overflow: false
|
|
|
|
|
2018-03-18 01:08:02 +09:00
|
|
|
macro_rules! m {
|
|
|
|
() => {};
|
|
|
|
($x: ident) => {};
|
|
|
|
($m1: ident, $m2: ident, $x: ident) => {};
|
|
|
|
($($beginning: ident),*; $middle: ident; $($end: ident),*) => {};
|
|
|
|
(
|
|
|
|
$($beginning: ident),*;
|
|
|
|
$middle: ident;
|
|
|
|
$($end: ident),*;
|
|
|
|
$($beginning: ident),*;
|
|
|
|
$middle: ident;
|
|
|
|
$($end: ident),*
|
|
|
|
) => {};
|
|
|
|
($name: ident($($dol: tt $var: ident)*) $($body: tt)*) => {};
|
2018-03-18 12:33:59 +09:00
|
|
|
(
|
2018-03-18 14:29:36 +09:00
|
|
|
$($i: ident : $ty: ty, $def: expr, $stb: expr, $($dstring: tt),+);+ $(;)*
|
|
|
|
$($i: ident : $ty: ty, $def: expr, $stb: expr, $($dstring: tt),+);+ $(;)*
|
2018-03-18 12:33:59 +09:00
|
|
|
) => {};
|
2018-03-18 13:12:16 +09:00
|
|
|
($foo: tt foo[$attr: meta] $name: ident) => {};
|
|
|
|
($foo: tt[$attr: meta] $name: ident) => {};
|
|
|
|
($foo: tt &'a[$attr: meta] $name: ident) => {};
|
|
|
|
($foo: tt foo #[$attr: meta] $name: ident) => {};
|
|
|
|
($foo: tt #[$attr: meta] $name: ident) => {};
|
|
|
|
($foo: tt &'a #[$attr: meta] $name: ident) => {};
|
|
|
|
($x: tt foo bar foo bar foo bar $y: tt => x * y * z $z: tt, $($a: tt),*) => {};
|
2018-03-18 01:08:02 +09:00
|
|
|
}
|
|
|
|
|
2018-03-18 14:08:24 +09:00
|
|
|
macro_rules! impl_a_method {
|
2018-03-18 14:29:36 +09:00
|
|
|
($n: ident($a: ident : $ta: ty) -> $ret: ty { $body: expr }) => {
|
2018-03-18 14:08:24 +09:00
|
|
|
fn $n($a: $ta) -> $ret {
|
|
|
|
$body
|
|
|
|
}
|
|
|
|
macro_rules! $n {
|
|
|
|
($va: expr) => {
|
|
|
|
$n($va)
|
|
|
|
};
|
|
|
|
}
|
|
|
|
};
|
2018-03-18 14:29:36 +09:00
|
|
|
($n: ident($a: ident : $ta: ty, $b: ident : $tb: ty) -> $ret: ty { $body: expr }) => {
|
2018-03-18 14:08:24 +09:00
|
|
|
fn $n($a: $ta, $b: $tb) -> $ret {
|
|
|
|
$body
|
|
|
|
}
|
|
|
|
macro_rules! $n {
|
|
|
|
($va: expr,$vb: expr) => {
|
|
|
|
$n($va, $vb)
|
|
|
|
};
|
|
|
|
}
|
|
|
|
};
|
|
|
|
(
|
2018-03-18 14:29:36 +09:00
|
|
|
$n: ident($a: ident : $ta: ty, $b: ident : $tb: ty, $c: ident : $tc: ty) ->
|
2018-03-18 14:08:24 +09:00
|
|
|
$ret: ty { $body: expr }
|
|
|
|
) => {
|
|
|
|
fn $n($a: $ta, $b: $tb, $c: $tc) -> $ret {
|
|
|
|
$body
|
|
|
|
}
|
|
|
|
macro_rules! $n {
|
|
|
|
($va: expr,$vb: expr,$vc: expr) => {
|
|
|
|
$n($va, $vb, $vc)
|
|
|
|
};
|
|
|
|
}
|
|
|
|
};
|
|
|
|
(
|
2018-03-18 14:29:36 +09:00
|
|
|
$n: ident($a: ident : $ta: ty, $b: ident : $tb: ty, $c: ident : $tc: ty, $d: ident : $td: ty) ->
|
2018-03-18 14:08:24 +09:00
|
|
|
$ret: ty { $body: expr }
|
|
|
|
) => {
|
|
|
|
fn $n($a: $ta, $b: $tb, $c: $tc, $d: $td) -> $ret {
|
|
|
|
$body
|
|
|
|
}
|
|
|
|
macro_rules! $n {
|
|
|
|
($va: expr,$vb: expr,$vc: expr,$vd: expr) => {
|
|
|
|
$n($va, $vb, $vc, $vd)
|
|
|
|
};
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2018-01-24 19:09:49 +00:00
|
|
|
macro_rules! m {
|
2018-01-30 17:05:31 +00:00
|
|
|
// a
|
2018-01-25 14:20:17 +00:00
|
|
|
($expr: expr, $($func: ident)*) => {{
|
2018-01-25 14:06:37 +00:00
|
|
|
let x = $expr;
|
|
|
|
$func(x)
|
|
|
|
}};
|
2018-01-24 19:09:49 +00:00
|
|
|
|
2018-01-30 17:05:31 +00:00
|
|
|
/* b */
|
|
|
|
() => {
|
|
|
|
/* c */
|
|
|
|
};
|
|
|
|
|
|
|
|
(@tag) => {};
|
2018-01-24 19:09:49 +00:00
|
|
|
|
2018-01-30 17:05:31 +00:00
|
|
|
// d
|
2018-01-24 19:09:49 +00:00
|
|
|
($item: ident) => {
|
|
|
|
mod macro_item {
|
|
|
|
struct $item;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
2018-01-30 17:05:31 +00:00
|
|
|
|
|
|
|
macro m2 {
|
|
|
|
// a
|
|
|
|
($expr: expr, $($func: ident)*) => {{
|
|
|
|
let x = $expr;
|
|
|
|
$func(x)
|
|
|
|
}}
|
|
|
|
|
|
|
|
/* b */
|
|
|
|
() => {
|
|
|
|
/* c */
|
|
|
|
}
|
|
|
|
|
|
|
|
(@tag) => {}
|
|
|
|
|
|
|
|
// d
|
|
|
|
($item: ident) => {
|
|
|
|
mod macro_item {
|
|
|
|
struct $item;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2018-02-14 04:00:26 +09:00
|
|
|
|
2018-02-23 08:10:17 +09:00
|
|
|
// #2438, #2476
|
2018-02-14 05:10:43 +09:00
|
|
|
macro_rules! m {
|
|
|
|
() => {
|
2018-02-23 08:10:17 +09:00
|
|
|
fn foo() {
|
|
|
|
this_line_is_98_characters_long_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
macro_rules! m {
|
|
|
|
() => {
|
|
|
|
fn foo() {
|
|
|
|
this_line_is_99_characters_long_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx(
|
|
|
|
);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
macro_rules! m {
|
|
|
|
() => {
|
|
|
|
fn foo() {
|
|
|
|
this_line_is_100_characters_long_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx(
|
|
|
|
);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
macro_rules! m {
|
|
|
|
() => {
|
|
|
|
fn foo() {
|
|
|
|
this_line_is_101_characters_long_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx(
|
|
|
|
);
|
|
|
|
}
|
2018-02-14 05:10:43 +09:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2018-02-14 04:00:26 +09:00
|
|
|
// #2439
|
|
|
|
macro_rules! m {
|
|
|
|
(
|
|
|
|
$line0_xxxxxxxxxxxxxxxxx: expr,
|
|
|
|
$line1_xxxxxxxxxxxxxxxxx: expr,
|
|
|
|
$line2_xxxxxxxxxxxxxxxxx: expr,
|
|
|
|
$line3_xxxxxxxxxxxxxxxxx: expr,
|
|
|
|
) => {};
|
|
|
|
}
|
2018-02-19 14:08:33 +09:00
|
|
|
|
|
|
|
// #2466
|
|
|
|
// Skip formatting `macro_rules!` that are not using `{}`.
|
|
|
|
macro_rules! m (
|
|
|
|
() => ()
|
|
|
|
);
|
|
|
|
macro_rules! m [
|
|
|
|
() => ()
|
|
|
|
];
|
2018-02-20 14:48:46 +09:00
|
|
|
|
|
|
|
// #2470
|
|
|
|
macro foo($type_name: ident, $docs: expr) {
|
|
|
|
#[allow(non_camel_case_types)]
|
|
|
|
#[doc=$docs]
|
|
|
|
#[derive(Debug, Clone, Copy)]
|
|
|
|
pub struct $type_name;
|
|
|
|
}
|
2018-03-17 14:58:56 +09:00
|
|
|
|
2018-03-18 14:29:36 +09:00
|
|
|
// #2534
|
|
|
|
macro_rules! foo {
|
|
|
|
($a: ident : $b: ty) => {};
|
|
|
|
($a: ident $b: ident $c: ident) => {};
|
|
|
|
}
|
|
|
|
|
2018-03-17 14:58:56 +09:00
|
|
|
// #2538
|
|
|
|
macro_rules! add_message_to_notes {
|
|
|
|
($msg: expr) => {{
|
|
|
|
let mut lines = message.lines();
|
|
|
|
notes.push_str(&format!("\n{}: {}", level, lines.next().unwrap()));
|
|
|
|
for line in lines {
|
|
|
|
notes.push_str(&format!(
|
|
|
|
"\n{:indent$}{line}",
|
|
|
|
"",
|
|
|
|
indent = level.len() + 2,
|
|
|
|
line = line,
|
|
|
|
));
|
|
|
|
}
|
|
|
|
}};
|
|
|
|
}
|