Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure that drop order of async fn matches fn and that users cannot refer to generated arguments. #60437

Merged
merged 3 commits into from
May 2, 2019

Commits on May 1, 2019

  1. Ensure that drop order of async fn matches fn.

    This commit modifies the lowering of `async fn` arguments so that the
    drop order matches the equivalent `fn`.
    
    Previously, async function arguments were lowered as shown below:
    
        async fn foo(<pattern>: <ty>) {
          async move {
          }
        } // <-- dropped as you "exit" the fn
    
        // ...becomes...
        fn foo(__arg0: <ty>) {
          async move {
            let <pattern> = __arg0;
          } // <-- dropped as you "exit" the async block
        }
    
    After this PR, async function arguments will be lowered as:
    
        async fn foo(<pattern>: <ty>, <pattern>: <ty>, <pattern>: <ty>) {
          async move {
          }
        } // <-- dropped as you "exit" the fn
    
        // ...becomes...
        fn foo(__arg0: <ty>, __arg1: <ty>, __arg2: <ty>) {
          async move {
            let __arg2 = __arg2;
            let <pattern> = __arg2;
            let __arg1 = __arg1;
            let <pattern> = __arg1;
            let __arg0 = __arg0;
            let <pattern> = __arg0;
          } // <-- dropped as you "exit" the async block
        }
    
    If `<pattern>` is a simple ident, then it is lowered to a single
    `let <pattern> = <pattern>;` statement as an optimization.
    davidtwco committed May 1, 2019
    Configuration menu
    Copy the full SHA
    b05d5db View commit details
    Browse the repository at this point in the history
  2. Ensure that users cannot use generated arguments.

    This commit gensyms the generated ident for replacement arguments so
    that users cannot refer to them. It also ensures that levenshtein
    distance suggestions do not suggest gensymed identifiers.
    davidtwco committed May 1, 2019
    Configuration menu
    Copy the full SHA
    f47735c View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    1fedb0a View commit details
    Browse the repository at this point in the history