mirror of
https://github.com/allankoechke/rust.git
synced 2026-12-03 17:48:43 +00:00
63 lines
1.3 KiB
Rust
63 lines
1.3 KiB
Rust
//! Regression test for <https://github.com/rust-lang/rust/issues/135287>
|
|
//@ revisions: rpass1 rpass2
|
|
//@ edition:2021
|
|
#![allow(dead_code)]
|
|
|
|
use std::future::Future;
|
|
use std::marker::PhantomData;
|
|
use std::pin::Pin;
|
|
use std::task::{Context, Poll};
|
|
|
|
#[cfg(rpass1)]
|
|
struct SourceDocument {}
|
|
|
|
#[cfg(rpass2)]
|
|
enum SourceDocument {}
|
|
|
|
trait Loader {
|
|
type Value;
|
|
fn load(&self) -> impl Future<Output = Self::Value>;
|
|
}
|
|
|
|
struct SourceDocumentLoader;
|
|
impl Loader for SourceDocumentLoader {
|
|
type Value = SourceDocument;
|
|
async fn load(&self) -> Self::Value {
|
|
todo!()
|
|
}
|
|
}
|
|
|
|
struct ManualSend<T>(T);
|
|
unsafe impl<T: Send> Send for ManualSend<T> {}
|
|
|
|
struct PendingButCovariant<T>(PhantomData<T>);
|
|
impl<T> Future for PendingButCovariant<T> {
|
|
type Output = T;
|
|
|
|
fn poll(self: Pin<&mut Self>, _cx: &mut Context<'_>) -> Poll<Self::Output> {
|
|
Poll::Pending
|
|
}
|
|
}
|
|
|
|
struct DataLoader<T>(T);
|
|
impl<T> DataLoader<T> {
|
|
async fn load_one(&self) -> ManualSend<T::Value>
|
|
where
|
|
T: Loader,
|
|
{
|
|
PendingButCovariant(PhantomData).await
|
|
}
|
|
}
|
|
|
|
trait ContainerType {
|
|
fn resolve_field(&self) -> impl Future<Output = ()> + Send;
|
|
}
|
|
impl ContainerType for () {
|
|
async fn resolve_field(&self) {
|
|
let loader = DataLoader(SourceDocumentLoader);
|
|
loader.load_one().await;
|
|
}
|
|
}
|
|
|
|
fn main() {}
|