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

ices/94903.sh: fixed with no errors #1206

Merged
merged 1 commit into from
Apr 5, 2022
Merged

Conversation

github-actions[bot]
Copy link
Contributor

@github-actions github-actions bot commented Apr 5, 2022

Issue: rust-lang/rust#94903

rustc --edition 2018 - 2>&1 << EOF

// check-pass
// edition:2018

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

fn main() {
    f();
}

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

struct InMemoryStorage;

struct User<'dep> {
    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>>;
}

struct SaveUser<'a> {
    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>,
    {
        SaveUser { name: "Joe" }
            .execute()
            .await;
    }
}

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

EOF
=== stdout ===
warning: field is never read: `dep`
  --> <anon>:18:5
   |
18 |     dep: &'dep str,
   |     ^^^^^^^^^^^^^^
   |
   = note: `#[warn(dead_code)]` on by default

warning: field is never read: `name`
  --> <anon>:46:5
   |
46 |     name: &'a str,
   |     ^^^^^^^^^^^^^

warning: unused implementer of `Future` that must be used
 --> <anon>:8:5
  |
8 |     f();
  |     ^^^^
  |
  = note: `#[warn(unused_must_use)]` on by default
  = note: futures do nothing unless you `.await` or poll them

warning: unused `Result` that must be used
  --> <anon>:59:9
   |
59 | /         SaveUser { name: "Joe" }
60 | |             .execute()
61 | |             .await;
   | |___________________^
   |
   = note: this `Result` may be an `Err` variant, which should be handled

warning: 4 warnings emitted

=== stderr ===
==============

=== stdout ===
warning: field is never read: `dep`
  --> <anon>:18:5
   |
18 |     dep: &'dep str,
   |     ^^^^^^^^^^^^^^
   |
   = note: `#[warn(dead_code)]` on by default

warning: field is never read: `name`
  --> <anon>:46:5
   |
46 |     name: &'a str,
   |     ^^^^^^^^^^^^^

warning: unused implementer of `Future` that must be used
 --> <anon>:8:5
  |
8 |     f();
  |     ^^^^
  |
  = note: `#[warn(unused_must_use)]` on by default
  = note: futures do nothing unless you `.await` or poll them

warning: unused `Result` that must be used
  --> <anon>:59:9
   |
59 | /         SaveUser { name: "Joe" }
60 | |             .execute()
61 | |             .await;
   | |___________________^
   |
   = note: this `Result` may be an `Err` variant, which should be handled

warning: 4 warnings emitted

=== stderr ===
==============
@Alexendoo Alexendoo merged commit db16ed0 into master Apr 5, 2022
@Alexendoo Alexendoo deleted the autofix/ices/94903.sh branch April 5, 2022 12:10
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