Skip to content

Prevent await from creating a generator #51719

Closed

Description

@cramertj

The await macro implemented in #51580 can be abused to create a generator (e.g. || await!()). This shouldn't be allowed.

Activity

  1. added
    T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
    on Jun 22, 2018
  2. BatmanAoD commented on Jul 10, 2018

    @BatmanAoD
    Contributor

    Is there an explanation somewhere of why this is necessarily bad?

  3. cramertj commented on Jul 11, 2018

    @cramertj
    MemberAuthor

    @BatmanAoD The fact that await!() internally uses yield is an implementation detail which shouldn't be exposed to end users. Eventually we'd like to be able to use async generators (where both yield and await are valid and mean very different things) in order to write Streams.

  4. BatmanAoD commented on Jul 11, 2018

    @BatmanAoD
    Contributor

    Ah, okay.

    Is there any compelling reason to permit await! inside a closure at all, with any semantics?

  5. cramertj commented on Jul 11, 2018

    @cramertj
    MemberAuthor

    @BatmanAoD Non-async closures? No. await shouldn't be allowed outside of async closures, blocks, and functions.

  6. BatmanAoD commented on Jul 11, 2018

    @BatmanAoD
    Contributor

    Oh, I didn't notic that the async/await RFC permitted specifying that a closure could be async. Yes, I meant non-async closures.

    Inside of async closures, permitting await! as-is shouldn't really be a problem, right?

  7. tmandry commented on Mar 13, 2019

    @tmandry
    Member

    Should this be tagged as AsyncAwait-Blocker?

  8. cramertj commented on Mar 13, 2019

    @cramertj
    MemberAuthor

    Yup!

  9. cramertj commented on Mar 13, 2019

    @cramertj
    MemberAuthor

    (but it's also in the group of issues that would be obviously fixed by native syntax)

  10. added a commit that references this issue on May 7, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    AsyncAwait-PolishAsync-await issues that are part of the "polish" areaT-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