-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make it into a structured suggestion, maybe-incorrect
- Loading branch information
1 parent
8960a12
commit 284d3cf
Showing
4 changed files
with
110 additions
and
2 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
21 changes: 21 additions & 0 deletions
21
tests/ui/async-await/async-closures/lint-closure-returning-async-block.rs
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,21 @@ | ||
//@ edition: 2021 | ||
|
||
#![feature(async_closure)] | ||
#![deny(closure_returning_async_block)] | ||
|
||
fn main() { | ||
let x = || async {}; | ||
//~^ ERROR closure returning async block can be made into an async closure | ||
|
||
let x = || async move {}; | ||
//~^ ERROR closure returning async block can be made into an async closure | ||
|
||
let x = move || async move {}; | ||
//~^ ERROR closure returning async block can be made into an async closure | ||
|
||
let x = move || async {}; | ||
//~^ ERROR closure returning async block can be made into an async closure | ||
|
||
let x = || {{ async {} }}; | ||
//~^ ERROR closure returning async block can be made into an async closure | ||
} |
67 changes: 67 additions & 0 deletions
67
tests/ui/async-await/async-closures/lint-closure-returning-async-block.stderr
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,67 @@ | ||
error: closure returning async block can be made into an async closure | ||
--> $DIR/lint-closure-returning-async-block.rs:7:13 | ||
| | ||
LL | let x = || async {}; | ||
| ^^ ----- this async block can be removed, and the closure can be turned into an async closure | ||
| | ||
note: the lint level is defined here | ||
--> $DIR/lint-closure-returning-async-block.rs:4:9 | ||
| | ||
LL | #![deny(closure_returning_async_block)] | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
help: turn this into an async closure | ||
| | ||
LL - let x = || async {}; | ||
LL + let x = async || {}; | ||
| | ||
|
||
error: closure returning async block can be made into an async closure | ||
--> $DIR/lint-closure-returning-async-block.rs:10:13 | ||
| | ||
LL | let x = || async move {}; | ||
| ^^ ---------- this async block can be removed, and the closure can be turned into an async closure | ||
| | ||
help: turn this into an async closure | ||
| | ||
LL - let x = || async move {}; | ||
LL + let x = async || {}; | ||
| | ||
|
||
error: closure returning async block can be made into an async closure | ||
--> $DIR/lint-closure-returning-async-block.rs:13:13 | ||
| | ||
LL | let x = move || async move {}; | ||
| ^^^^^^^ ---------- this async block can be removed, and the closure can be turned into an async closure | ||
| | ||
help: turn this into an async closure | ||
| | ||
LL - let x = move || async move {}; | ||
LL + let x = async move || {}; | ||
| | ||
|
||
error: closure returning async block can be made into an async closure | ||
--> $DIR/lint-closure-returning-async-block.rs:16:13 | ||
| | ||
LL | let x = move || async {}; | ||
| ^^^^^^^ ----- this async block can be removed, and the closure can be turned into an async closure | ||
| | ||
help: turn this into an async closure | ||
| | ||
LL - let x = move || async {}; | ||
LL + let x = async move || {}; | ||
| | ||
|
||
error: closure returning async block can be made into an async closure | ||
--> $DIR/lint-closure-returning-async-block.rs:19:13 | ||
| | ||
LL | let x = || {{ async {} }}; | ||
| ^^ ----- this async block can be removed, and the closure can be turned into an async closure | ||
| | ||
help: turn this into an async closure | ||
| | ||
LL - let x = || {{ async {} }}; | ||
LL + let x = async || {{ {} }}; | ||
| | ||
|
||
error: aborting due to 5 previous errors | ||
|