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

Allow conditional compilation when using wasm_bindgen proc-macro #3671

Open
nappa85 opened this issue Oct 27, 2023 · 3 comments
Open

Allow conditional compilation when using wasm_bindgen proc-macro #3671

nappa85 opened this issue Oct 27, 2023 · 3 comments
Labels

Comments

@nappa85
Copy link

nappa85 commented Oct 27, 2023

Describe the Bug

I'm able to apply conditionally wasm_bindgen proc-macro, but not his attributes

Steps to Reproduce

let's say we have a "wasm" feature

#[cfg_attr(feature = "wasm", wasm_bindgen_macro::wasm_bindgen)]
pub MyStruct {
  #[cfg_attr(feature = "wasm", wasm_bindgen(skip))] // THIS DOESN'T WORK
  pub my_field: MyWrapperType,
}

Expected Behavior

I'm able to use proc-macro attributes when using conditional compilation

Actual Behavior

cannot find attribute `wasm_bindgen` in this scope
`wasm_bindgen` is in scope, but it is a crate, not an attribute
consider importing one of these items:
  use wasm_bindgen::prelude::wasm_bindgen;
  use wasm_bindgen_macro::wasm_bindgen;
@nappa85 nappa85 added the bug label Oct 27, 2023
@ranile
Copy link
Collaborator

ranile commented Oct 27, 2023

You don't need the cfg_attr if your entire struct cfg'd out. But I can totally see a situation where conditionally applying wasm-bindgen attributes to fields is needed so this issue should be fixed.

@nappa85
Copy link
Author

nappa85 commented Oct 27, 2023 via email

@luke-biel
Copy link

Any chance for someone to look at this? I stumbled upon same issue in my code as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants