From 9318b4d2cfc3690812a4cad93934d505d1a6f72d Mon Sep 17 00:00:00 2001 From: Ingvar Stepanyan Date: Wed, 24 Jan 2018 19:25:57 +0000 Subject: [PATCH] Update some macro tests --- src/bin/cargo-fmt.rs | 2 +- tests/target/macro_not_expr.rs | 3 +- tests/target/macros.rs | 50 ++++++++++++++++++++-------------- 3 files changed, 33 insertions(+), 22 deletions(-) diff --git a/src/bin/cargo-fmt.rs b/src/bin/cargo-fmt.rs index 180c6f0abf3..2c5f16b46fb 100644 --- a/src/bin/cargo-fmt.rs +++ b/src/bin/cargo-fmt.rs @@ -97,7 +97,7 @@ fn execute() -> i32 { } macro_rules! print_usage { - ($print:ident, $opts:ident, $reason:expr) => ({ + ($print: ident, $opts: ident, $reason: expr) => ({ let msg = format!("{}\nusage: cargo fmt [options]", $reason); $print!( "{}\nThis utility formats all bin and lib files of the current crate using rustfmt. \ diff --git a/tests/target/macro_not_expr.rs b/tests/target/macro_not_expr.rs index d8de4dce38f..20dcfe2d622 100644 --- a/tests/target/macro_not_expr.rs +++ b/tests/target/macro_not_expr.rs @@ -1,5 +1,6 @@ macro_rules! test { - ($($t:tt)*) => {} + ($($t: tt)*) => { + }; } fn main() { diff --git a/tests/target/macros.rs b/tests/target/macros.rs index a79eb8fb294..471c90bf470 100644 --- a/tests/target/macros.rs +++ b/tests/target/macros.rs @@ -141,7 +141,8 @@ fn issue_1555() { fn issue1178() { macro_rules! foo { - (#[$attr:meta] $name:ident) => {} + (#[$attr: meta] $name: ident) => { + }; } foo!( @@ -246,11 +247,15 @@ fn __bindgen_test_layout_HandleWithDtor_open0_int_close0_instantiation() { // #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 @@ -885,24 +890,29 @@ fn macro_in_pattern_position() { }; } -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 { + () => { } } -macro foo() { - // a comment - fn foo() { - // another comment - bar(); +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(); + } } }