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

Fix/matches span #400

Merged
merged 2 commits into from Jun 12, 2020
Merged

Fix/matches span #400

merged 2 commits into from Jun 12, 2020

Commits on Jun 12, 2020

  1. Use proper span when generating matches token

    In `struct-opt-derive`, a function is generated with a parameter named
    `matches`. Since `quote!` is used to generate the function, the
    `matches` token will be resolved using `Span::call_site`.
    
    However, the literal identifier `matches` is also used inside several
    `quote_spanned!` expressions. Such a `matches` identifier will be
    resolved using the `Span` passed to `quote_spanned!`, which may not be
    the same as `Span::call_site`.
    
    Currently, this is difficult to observe in practice, due to
    rust-lang/rust#43081 . However, once PR rust-lang/rust#73084
    is merged, proc macros will see properly spanned tokens in more cases,
    which will cause these incorrect uses of `quote_spanned!` to break.
    
    This PR uses `quote! { matches }` to generate a correctly spanned
    `matches` token, which is then include in the `quote_spanned!`
    expressions using `#matches`.
    Aaron1011 authored and CreepySkeleton committed Jun 12, 2020
    Configuration menu
    Copy the full SHA
    0a6bc51 View commit details
    Browse the repository at this point in the history
  2. Some tweaks

    CreepySkeleton committed Jun 12, 2020
    Configuration menu
    Copy the full SHA
    83894e2 View commit details
    Browse the repository at this point in the history