forked from tokio-rs/tokio
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The macros `tokio::main` and `tokio::test` return invalid error messages if the function being wrapped has no return value. This was because the semicolon from the last statement was missing. Also, since version 0.1.54 (or earlier), `clippy::semicolon_if_nothing_returned` triggered false-negative when using the macros `tokio::test` and `tokio::main` on functions without a result type. We can copy the semicolon and the `return` keyword from the last statement from the body of the wrapped function. Fixes: rust-lang/rust-clippy#7438
- Loading branch information
Showing
7 changed files
with
56 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#[cfg(feature = "full")] | ||
#[tokio::test] | ||
async fn test_with_semicolon_without_return_type() { | ||
#![deny(clippy::semicolon_if_nothing_returned)] | ||
|
||
dbg!(0); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
use tests_build::tokio; | ||
|
||
#[tokio::main] | ||
async fn main() -> Result<(), ()> { | ||
loop { | ||
if !never() { | ||
return Ok(()); | ||
} | ||
} | ||
} | ||
|
||
fn never() -> bool { | ||
std::time::Instant::now() > std::time::Instant::now() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
use tests_build::tokio; | ||
|
||
#[tokio::main] | ||
async fn main() -> Result<(), ()> { | ||
return Ok(()); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters