Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow
async {}
expressions in const contexts
- Loading branch information
1 parent
8cf990c
commit bd16825
Showing
10 changed files
with
70 additions
and
19 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 |
---|---|---|
@@ -1,8 +1,19 @@ | ||
// From <https://github.com/rust-lang/rust/issues/77361> | ||
// gate-test-const_async_blocks | ||
|
||
// edition:2018 | ||
// revisions: with_feature without_feature | ||
|
||
#![feature(rustc_attrs)] | ||
#![cfg_attr(with_feature, feature(const_async_blocks))] | ||
|
||
use std::future::Future; | ||
|
||
// From <https://github.com/rust-lang/rust/issues/77361> | ||
const _: i32 = { core::mem::ManuallyDrop::new(async { 0 }); 4 }; | ||
//~^ `async` block | ||
//[without_feature]~^ `async` block | ||
|
||
static _FUT: &(dyn Future<Output = ()> + Sync) = &async {}; | ||
//[without_feature]~^ `async` block | ||
|
||
fn main() {} | ||
#[rustc_error] | ||
fn main() {} //[with_feature]~ fatal error triggered by #[rustc_error] |
This file was deleted.
Oops, something went wrong.
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,8 @@ | ||
error: fatal error triggered by #[rustc_error] | ||
--> $DIR/async-block.rs:19:1 | ||
| | ||
LL | fn main() {} | ||
| ^^^^^^^^^ | ||
|
||
error: aborting due to previous error | ||
|
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,19 @@ | ||
error[E0658]: `async` blocks are not allowed in constants | ||
--> $DIR/async-block.rs:12:47 | ||
| | ||
LL | const _: i32 = { core::mem::ManuallyDrop::new(async { 0 }); 4 }; | ||
| ^^^^^^^^^^^ | ||
| | ||
= help: add `#![feature(const_async_blocks)]` to the crate attributes to enable | ||
|
||
error[E0658]: `async` blocks are not allowed in statics | ||
--> $DIR/async-block.rs:15:51 | ||
| | ||
LL | static _FUT: &(dyn Future<Output = ()> + Sync) = &async {}; | ||
| ^^^^^^^^ | ||
| | ||
= help: add `#![feature(const_async_blocks)]` to the crate attributes to enable | ||
|
||
error: aborting due to 2 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0658`. |
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