-
Notifications
You must be signed in to change notification settings - Fork 12.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add new error code E0752 * Add span to hir::IsAsync::Yes * Emit an error if main or the start function is marked as async * Add two regression tests Fix formatting errors and bless test outputs * move tests to ui/async-await fix test error text remove span from IsAsync
- Loading branch information
Sebastian Malton
committed
Apr 20, 2020
1 parent
8d67f57
commit 6120ace
Showing
9 changed files
with
88 additions
and
14 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
`fn main()` or the specified start function is not allowed to be | ||
async. You might be seeing this error because your async runtime | ||
library is not set up correctly. | ||
|
||
Erroneous code example: | ||
|
||
```compile_fail,E0752 | ||
async fn main() -> Result<i32, ()> { | ||
Ok(1) | ||
} | ||
``` |
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,9 @@ | ||
// edition:2018 | ||
|
||
#![feature(start)] | ||
|
||
#[start] | ||
pub async fn start(_: isize, _: *const *const u8) -> isize { | ||
//~^ ERROR start is not allowed to be `async` | ||
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,9 @@ | ||
error[E0752]: start is not allowed to be `async` | ||
--> $DIR/issue-68523-start.rs:6:1 | ||
| | ||
LL | pub async fn start(_: isize, _: *const *const u8) -> isize { | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ start is not allowed to be `async` | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0752`. |
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 @@ | ||
// edition:2018 | ||
|
||
async fn main() -> Result<i32, ()> { | ||
//~^ ERROR `main` function is not allowed to be `async` | ||
//~^^ ERROR `main` has invalid return type `impl std::future::Future` | ||
Ok(1) | ||
} |
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,18 @@ | ||
error[E0277]: `main` has invalid return type `impl std::future::Future` | ||
--> $DIR/issue-68523.rs:3:20 | ||
| | ||
LL | async fn main() -> Result<i32, ()> { | ||
| ^^^^^^^^^^^^^^^ `main` can only return types that implement `std::process::Termination` | ||
| | ||
= help: consider using `()`, or a `Result` | ||
|
||
error[E0752]: `main` function is not allowed to be `async` | ||
--> $DIR/issue-68523.rs:3:1 | ||
| | ||
LL | async fn main() -> Result<i32, ()> { | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `main` function is not allowed to be `async` | ||
|
||
error: aborting due to 2 previous errors | ||
|
||
Some errors have detailed explanations: E0277, E0752. | ||
For more information about an error, try `rustc --explain E0277`. |