Skip to content

Diagnostic involving the type of an async block refers to generator's #81457

Closed
@guswynn

Description

@guswynn

version 1.49:

https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=6cf5c01427a274fed3395916ea86ab87

FuturesUnordered requires futures with the same type:

use futures::stream::FuturesUnordered;
fn main() {

    let u = FuturesUnordered::new();
    
    u.push(async {});
    u.push(async {});
    
}

results in:

error[E0308]: mismatched types
  --> src/main.rs:12:18
   |
11 |     u.push(async {});
   |                  -- the expected generator
12 |     u.push(async {});
   |                  ^^ expected generator, found a different generator
   |
   = note: expected generator `[static generator@src/main.rs:11:18: 11:20]`
              found generator `[static generator@src/main.rs:12:18: 12:20]`

As far as I know, generators have 2 types in their internal representation, so their display impl (its not actually display as far as I remember, but whatever creates the string to describe a type), should me more accurate about it being a future

also, these spans seem off?

@rustbot label +A-async-await +A-diagnostics +D-papercut

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-async-awaitArea: Async & AwaitA-diagnosticsArea: Messages for errors, warnings, and lintsAsyncAwait-TriagedAsync-await issues that have been triaged during a working group meeting.D-papercutDiagnostics: An error or lint that needs small tweaks.E-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.

    Type

    No type

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions