Skip to content

Typo in error output: Instead of clone()..await it should be .clone().await #110761

Closed
@Boscop

Description

@Boscop

Code

// Full code: https://play.rust-lang.org/?version=nightly&mode=debug&edition=2021&gist=03b0d135b9b888d739a99a580d406314
    let g = async || 1;
    let h = async || 1;
    let f = {
        let g_plus_h = memoize!(g().await + h().await);
        let two_plus_two = memoize!(2 + 2);
        async move || -> Vec<Shared<Pin<Box<dyn Future<Output = i64> + Send + 'static>>>> {
            vec![g_plus_h, two_plus_two]
        }
    };
    let a = f().await[0].await;
    let b = f().await[1].await;

Current output

error[E0507]: cannot move out of index of `Vec<Shared<Pin<Box<dyn futures::Future<Output = i64> + std::marker::Send>>>>`
  --> src/main.rs:62:13
   |
62 |     let a = f().await[0].await;
   |             ^^^^^^^^^^^^------ value moved due to this method call
   |             |
   |             move occurs because value has type `Shared<Pin<Box<dyn futures::Future<Output = i64> + std::marker::Send>>>`, which does not implement the `Copy` trait
   |
note: `std::future::IntoFuture::into_future` takes ownership of the receiver `self`, which moves value
  --> /rustc/7f94b314cead7059a71a265a8b64905ef2511796/library/core/src/future/into_future.rs:128:20
help: you can `clone` the value and consume it, but this might not be your desired behavior
   |
62 |     let a = f().await[0]clone()..await;
   |                         ++++++++

Desired output

Instead of `clone()..await` it should be `.clone().await`.

Rationale and extra context

image

Other cases

No response

Anything else?

No response

Metadata

Metadata

Labels

A-diagnosticsArea: Messages for errors, warnings, and lintsT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions