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

Remove span in generated field getter #3725

Merged
merged 4 commits into from
Nov 29, 2023
Merged

Commits on Nov 29, 2023

  1. Remove span in generated field getter

    Fixes rustwasm#3707
    
    Previously, `(*js).borrow().#rust_name` was being given the span of
    `rust_name`, which seems like a fairly harmless thing to do at first
    glance. However, it turns out that the span of a token also affects its
    hygiene - turns out proc macros have hygiene too, not just declarative
    macros!
    
    This caused a problem because the declaration of `js` had a span of
    `Span::call_site()`, but it was being accessed with `rust_name`'s span,
    which might be a different context where `js` doesn't exist.
    
    Usually this is fine because `Span::call_site()` is in the same context
    as the struct definition: normal code. However, when you put
    `#[wasm_bindgen]` inside a `macro_rules!`, `Span::call_site()` is now in
    the context of that `macro_rules!`, while `rust_name`'s span is still in
    normal code which can't access variables from inside `macro_rules!`.
    
    To fix that I've just removed the span from `(*js).borrow().#rust_name`,
    making it `Span::call_site()`. I don't think this should have any effect
    on diagnostics anyway, since I don't see how that code could ever cause
    a compile error.
    Liamolucko committed Nov 29, 2023
    Configuration menu
    Copy the full SHA
    d74450f View commit details
    Browse the repository at this point in the history
  2. Add test

    Liamolucko committed Nov 29, 2023
    Configuration menu
    Copy the full SHA
    22343b1 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    3bed9d2 View commit details
    Browse the repository at this point in the history
  4. Add changelog entry

    Liamolucko committed Nov 29, 2023
    Configuration menu
    Copy the full SHA
    e63e36e View commit details
    Browse the repository at this point in the history