Remove span in generated field getter #3725
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #3707
Previously,
(*js).borrow().#rust_name
was being given the span ofrust_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 ofSpan::call_site()
, but it was being accessed withrust_name
's span, which might be a different context wherejs
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 amacro_rules!
,Span::call_site()
is now in the context of thatmacro_rules!
, whilerust_name
's span is still in normal code which can't access variables from insidemacro_rules!
.To fix that I've just removed the span fromTurns out it was used, so I just got rid of the span on(*js).borrow().#rust_name
, making itSpan::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.js
instead of the whole thing.