diff options
| author | Oli Scherer <git-spam-no-reply9815368754983@oli-obk.de> | 2024-04-15 11:20:33 +0000 |
|---|---|---|
| committer | Oli Scherer <git-spam-no-reply9815368754983@oli-obk.de> | 2024-06-13 10:41:52 +0000 |
| commit | c75f7283bf52c6e2ec6a178f2b7717a4daddacf4 (patch) | |
| tree | 05d2c77ddb1ba67d34880c15d0a271b7af1cb9dc /tests/ui/impl-trait/recursive-parent-trait-method-call.rs | |
| parent | b28221e74f5f05d0f7a6212f99c9d5af868c0ed3 (diff) | |
| download | rust-c75f7283bf52c6e2ec6a178f2b7717a4daddacf4.tar.gz rust-c75f7283bf52c6e2ec6a178f2b7717a4daddacf4.zip | |
Add some tests
Diffstat (limited to 'tests/ui/impl-trait/recursive-parent-trait-method-call.rs')
| -rw-r--r-- | tests/ui/impl-trait/recursive-parent-trait-method-call.rs | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/tests/ui/impl-trait/recursive-parent-trait-method-call.rs b/tests/ui/impl-trait/recursive-parent-trait-method-call.rs new file mode 100644 index 00000000000..4da9a06a465 --- /dev/null +++ b/tests/ui/impl-trait/recursive-parent-trait-method-call.rs @@ -0,0 +1,42 @@ +//! This test checks that we can resolve the `boxed` method call to `FutureExt`, +//! because we know that the anonymous future does not implement `StreamExt`. + +//@ edition: 2021 +//@ check-pass + +use std::future::Future; +use std::pin::Pin; + +trait FutureExt: Future + Sized + Send + 'static { + fn boxed(self) -> Pin<Box<dyn Future<Output = Self::Output> + Send + 'static>> { + Box::pin(self) + } +} + +trait StreamExt: Future + Sized + Send + 'static { + fn boxed(self) -> Pin<Box<dyn Future<Output = Self::Output> + Send + 'static>> { + Box::pin(self) + } +} + +impl<T: Future + Sized + Send + 'static> FutureExt for T {} + +fn go(i: usize) -> impl Future<Output = ()> + Send + 'static { + async move { + if i != 0 { + spawn(async move { + let fut = go(i - 1).boxed(); + fut.await; + }) + .await; + } + } +} + +pub fn spawn<T: Send>( + _: impl Future<Output = T> + Send + 'static, +) -> impl Future<Output = ()> + Send + 'static { + async move { todo!() } +} + +fn main() {} |
