Skip to content

Provide appropriate suggestions for some of the discussed await syntaxes #60613

Closed

Description

@estebank

Regardless of the final syntax selected for await, given the prevalence of prefix keyword in other languages, and the possibility of thinking it is a method, the parser should support these syntaxes and error with an appropriate targeted diagnostic. Furthermore, should the field or method syntax were to be chosen, we should have reasonable behavior with explanations when accidentally using await when trying to access a field or call a similar method both inside and outside of async blocks.

Activity

  1. added
    T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
    on May 7, 2019
  2. estebank commented on May 7, 2019

    @estebank
    ContributorAuthor

    Some of the cases to have tests for:

    async fn foo() {
        let _ = await bar();
    }
    async fn foo() {
        let _ = await? bar();
    }
    async fn foo() {
        let _ = await bar()?;
    }
    async fn foo() {
        let _ = (await bar())?;
    }
    async fn foo() {
        let _ = bar().await();
    }
    async fn foo() {
        let _ = bar().await()?;
    }
    async fn foo() {
        let _ = bar().await;
    }
    async fn foo() {
        let _ = bar().await?;
    }
    fn foo() {
        let _ = await bar();
    }
    fn foo() {
        let _ = await? bar();
    }
    fn foo() {
        let _ = await bar()?;
    }
    fn foo() {
        let _ = (await bar())?;
    }
    fn foo() {
        let _ = bar().await();
    }
    fn foo() {
        let _ = bar().await()?;
    }
    fn foo() {
        let _ = bar().await;
    }
    fn foo() {
        let _ = bar().await?;
    }
    

    And we should have structs that have both similar method and field names, including r#await.

  3. Centril commented on May 7, 2019

    @Centril
    Contributor

    the parser should support these syntaxes and error with an appropriate targeted diagnostic

    As long as you make sure that this doesn't stabilize the syntax (i.e. you need to account for macros) then I think this is a good idea.

  4. estebank commented on May 7, 2019

    @estebank
    ContributorAuthor
  5. added a commit that references this issue on May 17, 2019
    70b38d1
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

    A-async-awaitArea: Async & AwaitA-diagnosticsArea: Messages for errors, warnings, and lintsA-suggestion-diagnosticsArea: Suggestions generated by the compiler applied by `cargo fix`T-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