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

Use correct edition when parsing :pat matchers #85709

Merged
merged 1 commit into from
May 30, 2021

Commits on May 29, 2021

  1. Use correct edition when parsing :pat matchers

    As described in issue rust-lang#85708, we currently do not properly decode
    `SyntaxContext::root()` and `ExpnId::root()` from foreign crates. As a
    result, when we decode a span from a foreign crate with
    `SyntaxContext::root()`, we end up up considering it to have the edition
    of the *current* crate, instead of the foreign crate where it was
    originally created.
    
    A full fix for this issue will be a fairly significant undertaking.
    Fortunately, it's possible to implement a partial fix, which gives us
    the correct edition-dependent behavior for `:pat` matchers when the
    macro is loaded from another crate. Since we have the edition of the
    macro's defining crate available, we can 'recover' from seeing a
    `SyntaxContext::root()` and use the edition of the macro's defining
    crate.
    
    Any solution to issue rust-lang#85708 must reproduce the behavior of this
    targeted fix - properly preserving a foreign `SyntaxContext::root()`
    means (among other things) preserving its edition, which by definition
    is the edition of the foreign crate itself. Therefore, this fix moves us
    closer to the correct overall solution, and does not expose any new
    incorrect behavior to macros.
    Aaron1011 committed May 29, 2021
    Configuration menu
    Copy the full SHA
    d874ecc View commit details
    Browse the repository at this point in the history