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 proper span when emitting 'self' identifier #210

Merged
merged 1 commit into from
May 30, 2020

Commits on May 30, 2020

  1. Use proper span when emitting 'self' identifier

    Normally, the span of a field has the same hygiene context as
    `Span::call_site`. However, it's possible for a struct definition
    to be 'constructed' via a `macro_rules` macro such that the field
    has a different hygiene context. This will cause the expanded code
    to be unable to resolve any references to `self`, resulting in a
    compilation error.
    
    This pull request uses `quote!` instead of `quote_spanned!` when
    emitting a 'self' identifier. `quote_spanned!` is still used for
    everything else in the emitted method, meaning that error messages
    will still point to the proper field.
    
    I've included a test case which triggers this issue on
    Rust 1.43.1. It's current difficult to hit this issue
    other than in this artificial case, but that will change
    once rust-lang/rust#72622 is re-landed.
    Aaron1011 committed May 30, 2020
    Configuration menu
    Copy the full SHA
    2431f7e View commit details
    Browse the repository at this point in the history