fn issue1178() {
macro_rules! foo {
- (#[$attr:meta] $name:ident) => {}
+ (#[$attr: meta] $name: ident) => {};
}
foo!(
acc += 1;
acc += 2;
acc
- }
+ };
}
}
// #878
macro_rules! try_opt {
- ($expr:expr) => (match $expr {
- Some(val) => val,
+ ($expr: expr) => {
+ match $expr {
+ Some(val) => val,
- None => { return None; }
- })
+ None => {
+ return None;
+ }
+ }
+ };
}
// #2214
}
fn special_case_macros() {
+ let p = eprint!();
let q = eprint!("{}", 1);
let r = eprint!(
"{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}",
26
);
- assert!(result, "Ahoy there, {}!", target);
+ assert!();
+ assert!(result == 42);
+ assert!(result == 42, "Ahoy there, {}!", target);
assert!(
+ result == 42,
+ "Arr! While plunderin' the hold, we got '{}' when given '{}' (we expected '{}')",
result,
+ input,
+ expected
+ );
+ assert!(
+ result == 42,
+ "{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}",
+ 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
+ );
+
+ assert_eq!();
+ assert_eq!(left);
+ assert_eq!(left, right);
+ assert_eq!(left, right, "Ahoy there, {}!", target);
+ assert_eq!(
+ left, right,
"Arr! While plunderin' the hold, we got '{}' when given '{}' (we expected '{}')",
result, input, expected
);
- assert!(
+ assert_eq!(
+ first_realllllllllllly_long_variable_that_doesnt_fit_one_one_line,
+ second_reallllllllllly_long_variable_that_doesnt_fit_one_one_line,
+ "Arr! While plunderin' the hold, we got '{}' when given '{}' (we expected '{}')",
+ result,
+ input,
+ expected
+ );
+ assert_eq!(
+ left + 42,
+ right,
+ "Arr! While plunderin' the hold, we got '{}' when given '{}' (we expected '{}')",
result,
+ input,
+ expected
+ );
+ assert_eq!(
+ left,
+ right,
"{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}",
1,
2,
) => (),
};
}
+
+macro foo() {}
+
+pub macro bar($x: ident + $y: expr;) {
+ fn foo($x: Foo) {
+ long_function(
+ a_long_argument_to_a_long_function_is_what_this_is(AAAAAAAAAAAAAAAAAAAAAAAAAAAA),
+ $x.bar($y),
+ );
+ }
+}
+
+macro foo() {
+ // a comment
+ fn foo() {
+ // another comment
+ bar();
+ }
+}
+
+macro lex_err($kind: ident $(, $body: expr)*) {
+ Err(QlError::LexError(LexError::$kind($($body,)*)))
+}
+
+// Preserve trailing comma on item-level macro with `()` or `[]`.
+methods![get, post, delete,];
+methods!(get, post, delete,);