wasm-bindgen
wasm-bindgen copied to clipboard
Generated constants should be UPPER_SNAKE_CASE
Describe the Bug
Generated constants are not upper snake case and this triggers warnings from the rust-analyzer.
Steps to Reproduce
Save this code to a .rs file:
#[wasm_bindgen]
extern "C" {
pub type Something;
}
Import the required mods and run the rust-analyzer.
Expected Behavior
No warnings should appear.
Actual Behavior
The following error appears:
Diagnostic { code: DiagnosticCode("incorrect-ident-case"), message: "Constant `__wbg_generated_const_Something` should have UPPER_SNAKE_CASE name, e.g. `__WBG_GENERATED_CONST_SOMETHING`", range: 732..747, severity: WeakWarning, unused: false, experimental: false, fixes: Some([Assist { id: AssistId("change_case", QuickFix), label: "Rename to __WBG_GENERATED_CONST_SOMETHING", group: None, target: 732..747, source_change: None }]) }

Additional Context
I've tried to disable the warning by using #[allow(non_snake_case,non_upper_case_globals)] but it does not do the trick. I've also tried to tweak the rust-analyzer to ignore this but I also failed.
If you use #![allow(non_snake_case,non_upper_case_globals)] in the root of the crate, it silences the errors, although that turns it off in general. I believe that the #[automatically_derived] attribute doesn't work for clippy. Wasm-bindgen shoudl consider adding #[allow(non_snake_case, non_upper_case_globals)] to this generated function.
Seeing the same thing.
Similar to: https://github.com/rustwasm/wasm-bindgen/issues/2774
Would be great to see a general fix for the clippy issues.
I'm seeing the same issue. Can someone (a previous contributor) point me in the right direction to make a PR here?
Can someone (a previous contributor) point me in the right direction to make a PR here?
The macro's code generation is all defined in https://github.com/rustwasm/wasm-bindgen/blob/main/crates/backend/src/codegen.rs, so you'd have to find and fix all the instances where non-upper-snake-case names are generated in that file.
I made a PR. Can someone take a look?