Logo
Explore Help
Register Sign In
rust-lang/rust
1
0
Fork 0
You've already forked rust
Code Issues Pull Requests Actions 1 Packages Projects Releases Wiki Activity
Files
ea37e8091fe87ae0a7e204c034e7d55061e56790
rust/tests/ui/async-await/in-trait/async-example-desugared-boxed.rs

18 lines
304 B
Rust
Raw Normal View History

Add additional tests for static AFIT
2022-10-07 16:15:13 +00:00
// edition: 2021
use std::future::Future;
use std::pin::Pin;
trait MyTrait {
async fn foo(&self) -> i32;
}
impl MyTrait for i32 {
fn foo(&self) -> Pin<Box<dyn Future<Output = i32> + '_>> {
Ensure async trait impls are async (or otherwise return an opaque type) As a workaround for the full `#[refine]` semantics not being implemented yet, forbit returning a concrete future type like `Box<dyn Future>` or a manually implemented Future. `-> impl Future` is still permitted; while that can also cause accidental refinement, that's behind a different feature gate (`return_position_impl_trait_in_trait`) and that problem exists regardless of whether the trait method is async, so will have to be solved more generally. Fixes #102745
2022-11-02 17:45:08 -07:00
//~^ ERROR method `foo` should be async
Box::pin(async { *self })
Add additional tests for static AFIT
2022-10-07 16:15:13 +00:00
}
}
fn main() {}
Reference in New Issue Copy Permalink
Powered by Gitea Version: 1.24.6 Page: 582ms Template: 3ms
English
Bahasa Indonesia Deutsch English Español Français Gaeilge Italiano Latviešu Magyar nyelv Nederlands Polski Português de Portugal Português do Brasil Suomi Svenska Türkçe Čeština Ελληνικά Български Русский Українська فارسی മലയാളം 日本語 简体中文 繁體中文(台灣) 繁體中文(香港) 한국어
Licenses API