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

Name the captured upvars for closures/generators in debuginfo #85020

Merged
merged 4 commits into from
Aug 14, 2021

Commits on Jul 9, 2021

  1. Name the captured upvars for closures/generators in debuginfo

    Previously, debuggers print closures as something like
    ```
    y::main::closure-0 (0x7fffffffdd34)
    ```
    The pointer actually references to an upvar. It is not
    very obvious, especially for beginners.
    
    It's because upvars don't have names before, as they
    are packed into a tuple. This commit names the upvars,
    so we can expect to see something like
    ```
    y::main::closure-0 {_captured_ref__b: 0x[...]}
    ```
    lrh2000 committed Jul 9, 2021
    Configuration menu
    Copy the full SHA
    29856ac View commit details
    Browse the repository at this point in the history
  2. Store names of captured variables in optimized_mir

    - Closures in external crates may get compiled in because of
      monomorphization. We should store names of captured variables
      in `optimized_mir`, so that they are written into the metadata
      file and we can use them to generate debuginfo.
    
    - If there are breakpoints inside closures, the names of captured
      variables stored in `optimized_mir` can be used to print them.
      Now the name is more precise when disjoint fields are captured.
    lrh2000 committed Jul 9, 2021
    Configuration menu
    Copy the full SHA
    cda90f5 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    0cb6f07 View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    cf5eda1 View commit details
    Browse the repository at this point in the history