Skip to content

Commit

Permalink
Only remove the span from js
Browse files Browse the repository at this point in the history
  • Loading branch information
Liamolucko committed Nov 28, 2023
1 parent a009c37 commit 87ef336
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion crates/backend/src/codegen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,14 @@ impl ToTokens for ast::StructField {
};
let maybe_assert_copy = respan(maybe_assert_copy, ty);

let mut val = quote! { (*js).borrow().#rust_name };
// Split this out so that it isn't affected by `quote_spanned!`.
//
// If we don't do this, it might end up being unable to reference `js`
// properly because it doesn't have the same span.
//
// See https://github.com/rustwasm/wasm-bindgen/pull/3725.
let js_token = quote! { js };
let mut val = quote_spanned!(self.rust_name.span()=> (*#js_token).borrow().#rust_name);
if let Some(span) = self.getter_with_clone {
val = quote_spanned!(span=> <#ty as Clone>::clone(&#val) );
}
Expand Down

0 comments on commit 87ef336

Please sign in to comment.