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

Track span of function in method calls, and use this in #[track_caller] #73182

Merged
merged 6 commits into from
Jun 11, 2020

Commits on Jun 10, 2020

  1. Track span of function in method calls, and use this in #[track_caller]

    Fixes rust-lang#69977
    
    When we parse a chain of method calls like `foo.a().b().c()`, each
    `MethodCallExpr` gets assigned a span that starts at the beginning of
    the call chain (`foo`). While this is useful for diagnostics, it means
    that `Location::caller` will return the same location for every call
    in a call chain.
    
    This PR makes us separately record the span of the function name and
    arguments for a method call (e.g. `b()` in `foo.a().b().c()`). This
    `Span` is passed through HIR lowering and MIR building to
    `TerminatorKind::Call`, where it is used in preference to
    `Terminator.source_info.span` when determining `Location::caller`.
    
    This new span is also useful for diagnostics where we want to emphasize
    a particular method call - for an example, see
    rust-lang#72389 (comment)
    Aaron1011 committed Jun 10, 2020
    Configuration menu
    Copy the full SHA
    28946b3 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    6e4d0b4 View commit details
    Browse the repository at this point in the history
  3. Fix pprust-expr-roundtrip

    Aaron1011 committed Jun 10, 2020
    Configuration menu
    Copy the full SHA
    f69a2a6 View commit details
    Browse the repository at this point in the history
  4. Add doc comments

    Aaron1011 committed Jun 10, 2020
    Configuration menu
    Copy the full SHA
    bbf497b View commit details
    Browse the repository at this point in the history
  5. Clippy fixes

    Aaron1011 committed Jun 10, 2020
    Configuration menu
    Copy the full SHA
    e5f3b94 View commit details
    Browse the repository at this point in the history
  6. Fix test

    Aaron1011 committed Jun 10, 2020
    Configuration menu
    Copy the full SHA
    9d36fa3 View commit details
    Browse the repository at this point in the history