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
[BUG] only C-Style enums allowed with #[wasm_bindgen] / #[cfg] field not removed #3297
Comments
Real work example: https://github.com/erwanvivien/fast_qr/blob/master/src/convert/mod.rs#L34 |
Any update on this? |
This should be fairly easy to fix in the proc-macro. I'm happy to review a PR. |
Never worked on proc-macro, I'll check and see if I can manage a PR |
Hello @daxpedda I'm trying to do so, but I don't think it's doable in the proc-macro tho 🤔 I feel like there are many edge cases where the cfg could remove the Variant from an enum etc #[cfg(not(target_arch = "wasm32"))]
#[cfg_attr(target_arch = "wasm32", cfg(not(target_arch = "wasm32")))]
#[cfg(feature = "...")]
CUSTOM(fn(i32) -> i32), There are many cases that needs to be handled and writing a function for each of those could be fragile |
provides a way to avoid havind this error: only C-Style enums allowed with #[wasm_bindgen] ```rust \#[wasm_bindgen] pub enum Operation { INCREMENT, #[cfg(not(target_arch = "wasm32"))] #[wasm_bindgen(skip)] CUSTOM(fn(i32) -> i32), } ```
I think what you need to do here is to store any attributes that you find on a variant and emit them on every mention of that variant by the proc-macro. You should definitely not parse the Feel free to join us on Discord, where we can probably help you in more detail if you need it. |
provides a way to avoid having this error: only C-Style enums allowed with #[wasm_bindgen] ```rust \#[wasm_bindgen] pub enum Operation { INCREMENT, #[cfg(not(target_arch = "wasm32"))] #[wasm_bindgen(skip)] CUSTOM(fn(i32) -> i32), } ```
Describe the Bug
Cannot use a
#[cfg]
macro inside a#[wasm_bindgen]
enum ?Steps to Reproduce
cargo new test-wasm-enum --lib cd test-wasm-enum
replace lib.rs with:
Then:
Expected Behavior
No errors
Actual Behavior
When adding wasm_bindgen to my enum, it doesn't remove the cfg
I need to do:
Which is ugly...
The text was updated successfully, but these errors were encountered: