From 40d959263bc16771882b2d1c9356f1ec02957c3d Mon Sep 17 00:00:00 2001 From: Taiki Endo Date: Mon, 11 Jan 2021 19:20:40 +0900 Subject: [PATCH] macros: fix unused_braces in generated code (#3404) --- tokio-macros/src/entry.rs | 2 +- tokio/tests/macros_test.rs | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/tokio-macros/src/entry.rs b/tokio-macros/src/entry.rs index 8f80499b8..ae8c0b9d9 100644 --- a/tokio-macros/src/entry.rs +++ b/tokio-macros/src/entry.rs @@ -254,7 +254,7 @@ fn parse_knobs( .enable_all() .build() .unwrap() - .block_on(async { #body }) + .block_on(async #body) } }; diff --git a/tokio/tests/macros_test.rs b/tokio/tests/macros_test.rs index 8e68b8a44..839639814 100644 --- a/tokio/tests/macros_test.rs +++ b/tokio/tests/macros_test.rs @@ -17,3 +17,11 @@ async fn test_macro_is_resilient_to_shadowing() { .await .unwrap(); } + +// https://github.com/tokio-rs/tokio/issues/3403 +#[rustfmt::skip] // this `rustfmt::skip` is necessary because unused_braces does not warn if the block contains newline. +#[tokio::main] +async fn unused_braces_main() { println!("hello") } +#[rustfmt::skip] // this `rustfmt::skip` is necessary because unused_braces does not warn if the block contains newline. +#[tokio::test] +async fn unused_braces_test() { assert_eq!(1 + 1, 2) }