Skip to content

rust-analyzer: "Function __wasm_bindgen_generated... should have snake_case name" #4080

@elmarco

Description

@elmarco

Describe the Bug

rust-analyzer complains about generated fn names.

Steps to Reproduce

#[wasm_bindgen]
impl Session {
    pub fn desktop_size(&self) -> DesktopSize {
    ...
  }
}

Expands to

    pub fn desktop_size(&self) -> DesktopSize {
        #[automatically_derived]
        const _: () = {
            #[cfg_attr(
                all(target_arch = "wasm32", not(any(target_os = "emscripten", target_os = "wasi"))),
                export_name = "session_desktop_size"
            )]
            pub unsafe extern "C" fn __wasm_bindgen_generated_Session_desktop_size(
                me: u32,
            ) -> wasm_bindgen::convert::WasmRet<<DesktopSize as wasm_bindgen::convert::ReturnWasmAbi>::Abi>

Expected Behavior

No rust-analyzer warning

Actual Behavior

rust-analyzer warnings are emitted, such as

Function __wasm_bindgen_generated_Session_desktop_size should have snake_case name, e.g. __wasm_bindgen_generated_session_desktop_size

Additional Context

Given that the fn have an export name, couldn't the fn symbol name be simply lowercased?

Activity

daxpedda

daxpedda commented on Aug 20, 2024

@daxpedda
Collaborator

Given that the fn have an export name, couldn't the fn symbol name be simply lowercased?

Probably not, otherwise a different session::desktop_size() would collide.

I was unable to reproduce this issue, so it would probably be best if you could make a small but complete reproducible example.

gagbo

gagbo commented on Aug 23, 2024

@gagbo

I am having the issue with __wbg_instanceof_JsType from tsify (the issue) and weirdly I wasn’t able to repro in the playground either.

Tsify triggers the warning from this generated code:

https://github.com/madonoharu/tsify/blob/66cddfe680ae429be0063cf6e6b1b5be34bb7ce2/tsify-macros/src/wasm_bindgen.rs#L57-L61

I think this commit ddceac7 is the fix for this.

daxpedda

daxpedda commented on Aug 23, 2024

@daxpedda
Collaborator

Thank you for looking into this!

If this is ultimately not fixed by #4078, I'm happy to take a look again with a reproducible example.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @elmarco@daxpedda@gagbo

        Issue actions

          rust-analyzer: "Function __wasm_bindgen_generated... should have snake_case name" · Issue #4080 · rustwasm/wasm-bindgen