Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tracking Issue for async {} blocks in const expressions #85368

Open
1 of 3 tasks
jonas-schievink opened this issue May 16, 2021 · 4 comments
Open
1 of 3 tasks

Tracking Issue for async {} blocks in const expressions #85368

jonas-schievink opened this issue May 16, 2021 · 4 comments
Labels
A-const-eval Area: Constant evaluation, covers all const contexts (static, const fn, ...) C-tracking-issue Category: An issue tracking the progress of sth. like the implementation of an RFC F-const_async_blocks `#![feature(const_async_blocks)]`

Comments

@jonas-schievink
Copy link
Contributor

jonas-schievink commented May 16, 2021

This is a tracking issue for use of async {} expressions in const contexts.
The feature gate for the issue is #![feature(const_async_blocks)].

About tracking issues

Tracking issues are used to record the overall progress of implementation.
They are also used as hubs connecting to other relevant issues, e.g., bugs or open design questions.
A tracking issue is however not meant for large scale discussion, questions, or bug reports about a feature.
Instead, open a dedicated issue for the specific matter and add the relevant feature gate label.

Steps

Unresolved Questions

Implementation history

@jonas-schievink jonas-schievink added C-tracking-issue Category: An issue tracking the progress of sth. like the implementation of an RFC A-const-fn F-const_async_blocks `#![feature(const_async_blocks)]` labels May 16, 2021
@CryZe
Copy link
Contributor

CryZe commented May 16, 2021

Technically this already existed, but I'll close mine in favor of this one: #69431

@jonas-schievink
Copy link
Contributor Author

Ah okay, normally we don't have tracking issues for things that aren't implemented

@Swatinem
Copy link
Contributor

Hi! 👋🏻
I discovered while working on #104321 that async blocks can trivially be const as soon as the #104826 workaround is fixed.

Depending on whats happening with #104826, what would be the next steps in moving forward with the feature flag/stabilization?

@CryZe
Copy link
Contributor

CryZe commented May 5, 2023

Is there anything preventing this from getting stabilized? I'd like to do the remaining work to push this to stabilization.

CryZe added a commit to LiveSplit/asr that referenced this issue May 7, 2023
This allows you to define an asynchronous `main` function instead of the
poll based `update` function, which allows you to more easily keep state
between individual ticks of the runtime. Unfortunately the most
efficient implementation isn't possible yet on stable Rust, as we are
blocked by the following two features:
- [type_alias_impl_trait](rust-lang/rust#63063)
- [const_async_blocks](rust-lang/rust#85368)

For now we have to use a workaround that is less efficient by calling
the `main` function at runtime and allocating it onto a new WebAssembly
page.

Here is a full example of how an auto splitter could look like using the
`async_main` macro:

Usage on stable Rust:
```rust
async_main!(stable);
```

Usage on nightly Rust:
```rust

async_main!(nightly);
```

The asynchronous main function itself:
```rust
async fn main() {
    // TODO: Set up some general state and settings.
    loop {
        let process = Process::wait_attach("explorer.exe").await;
        process.until_closes(async {
            // TODO: Load some initial information from the process.
            loop {
                // TODO: Do something on every tick.
               next_tick().await;
            }
        }).await;
    }
}
```
CryZe added a commit to LiveSplit/asr that referenced this issue May 7, 2023
This allows you to define an asynchronous `main` function instead of the
poll based `update` function, which allows you to more easily keep state
between individual ticks of the runtime. Unfortunately the most
efficient implementation isn't possible yet on stable Rust, as we are
blocked by the following two features:
- [type_alias_impl_trait](rust-lang/rust#63063)
- [const_async_blocks](rust-lang/rust#85368)

For now we have to use a workaround that is less efficient by calling
the `main` function at runtime and allocating it onto a new WebAssembly
page.

Here is a full example of how an auto splitter could look like using the
`async_main` macro:

Usage on stable Rust:
```rust
async_main!(stable);
```

Usage on nightly Rust:
```rust

async_main!(nightly);
```

The asynchronous main function itself:
```rust
async fn main() {
    // TODO: Set up some general state and settings.
    loop {
        let process = Process::wait_attach("explorer.exe").await;
        process.until_closes(async {
            // TODO: Load some initial information from the process.
            loop {
                // TODO: Do something on every tick.
               next_tick().await;
            }
        }).await;
    }
}
```
CryZe added a commit to LiveSplit/asr that referenced this issue May 7, 2023
This allows you to define an asynchronous `main` function instead of the
poll based `update` function, which allows you to more easily keep state
between individual ticks of the runtime. Unfortunately the most
efficient implementation isn't possible yet on stable Rust, as we are
blocked by the following two features:
- [`type_alias_impl_trait`](rust-lang/rust#63063)
- [`const_async_blocks`](rust-lang/rust#85368)

For now we have to use a workaround that is less efficient by calling
the `main` function at runtime and allocating it onto a new WebAssembly
page.

Here is a full example of how an auto splitter could look like using the
`async_main` macro:

Usage on stable Rust:
```rust
async_main!(stable);
```

Usage on nightly Rust:
```rust

async_main!(nightly);
```

The asynchronous main function itself:
```rust
async fn main() {
    // TODO: Set up some general state and settings.
    loop {
        let process = Process::wait_attach("explorer.exe").await;
        process.until_closes(async {
            // TODO: Load some initial information from the process.
            loop {
                // TODO: Do something on every tick.
               next_tick().await;
            }
        }).await;
    }
}
```
@RalfJung RalfJung added A-const-eval Area: Constant evaluation, covers all const contexts (static, const fn, ...) and removed A-const-fn labels Dec 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-const-eval Area: Constant evaluation, covers all const contexts (static, const fn, ...) C-tracking-issue Category: An issue tracking the progress of sth. like the implementation of an RFC F-const_async_blocks `#![feature(const_async_blocks)]`
Projects
None yet
Development

No branches or pull requests

4 participants