Skip to content

Rust: Model async return types as dyn Future #20236

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

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

hvitved
Copy link
Contributor

@hvitved hvitved commented Aug 17, 2025

Instead of assigning the type Future directly, we assign dyn Future, just like we assign dyn FnOnce to closures. As @paldepind notes on that PR, using impl Future would be more faithful, but in terms of our type inference implementation the effect is the same.

@github-actions github-actions bot added the Rust Pull requests that update Rust code label Aug 17, 2025
// Type mentions required by type inference

use std::future::Future;
fn mention_dyn_future<T>(f: &dyn Future<Output = T>) {}

Check notice

Code scanning / CodeQL

Unused variable Note

Variable 'f' is not used.
use std::future::Future;
fn mention_dyn_future<T>(f: &dyn Future<Output = T>) {}

fn mention_dyn_fn_once<F>(f: &dyn FnOnce() -> F) {}

Check notice

Code scanning / CodeQL

Unused variable Note

Variable 'f' is not used.
@hvitved hvitved force-pushed the rust/type-inference-async-dyn-future branch from 37b1b73 to f847160 Compare August 18, 2025 08:45
@hvitved hvitved force-pushed the rust/type-inference-async-dyn-future branch from f847160 to f7f08f6 Compare August 19, 2025 08:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Rust Pull requests that update Rust code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant