Skip to content
This repository was archived by the owner on May 23, 2024. It is now read-only.

ices/80706.rs: fixed with no errors #929

Closed
wants to merge 1 commit into from

Conversation

github-actions[bot]
Copy link
Contributor

Issue: rust-lang/rust#80706

type BoxFuture<T> = std::pin::Pin<Box<dyn std::future::Future<Output = T>>>;

fn main() {
    let _ = f();
}

async fn f() {
    run("dependency").await;
}

struct InMemoryStorage;

pub struct User<'dep> {
    pub dep: &'dep str,
}

impl<'a> StorageRequest<InMemoryStorage> for SaveUser<'a> {
    fn execute(&self) -> BoxFuture<Result<(), String>> {
        todo!()
    }
}

trait Storage {
    type Error;
}

impl Storage for InMemoryStorage {
    type Error = String;
}

trait StorageRequestReturnType {
    type Output;
}

trait StorageRequest<S: Storage>: StorageRequestReturnType {
    fn execute(
        &self,
    ) -> BoxFuture<Result<<Self as StorageRequestReturnType>::Output, <S as Storage>::Error>>;
}

pub struct SaveUser<'a> {
    pub name: &'a str,
}

impl<'a> StorageRequestReturnType for SaveUser<'a> {
    type Output = ();
}

impl<'dep> User<'dep> {
    async fn save<S>(self)
    where
        S: Storage,
        for<'a> SaveUser<'a>: StorageRequest<S>,
    {
        let _ = SaveUser { name: "Joe" }.execute().await;
    }
}

async fn run<S>(dep: &str)
where
    S: Storage,
    for<'a> SaveUser<'a>: StorageRequest<S>,
{
    User { dep }.save().await;
}
=== stdout ===
=== stderr ===
==============

=== stdout ===
=== stderr ===
==============
@Alexendoo Alexendoo closed this Aug 29, 2021
@Alexendoo Alexendoo deleted the autofix/ices/80706.rs branch August 29, 2021 12:49
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants