Jetbrains editor: False positive duplicate method name for attribute macro #[update]

I’ve raised a support issue with JetBrains because my WebStorm editor has been flagging a few false positive errors. While they’ve opened an issue to track it https://youtrack.jetbrains.com/issue/RUST-12110 , I’m not entirely convinced it’s solely an editor problem. It started when I migrated Juno to the latest ic_cdk v0.11.0.

I’m curious if anyone else has encountered the same issue and possibly found a solution?


Here are screenshots of a few of the incorrect errors (cargo build is fine):

image

The #[update] and #[query] macros are actually stateful procedures.

As you can see, the create_satellite method with #[update] annotation was expanded with an extra function: create_satellite_15_ which is the actual method to be exported in the WASM module. The _15_ postfix was from a global counter to avoid name conflicts.

I suspect that intellij-rust (the Rust plugin of Intellij IDEs) cannot handle such stateful macros very well.

There was no change in relevant part of Rust CDK recently. If it did work well before, the new error must be from change in the IDE or the plugin.

1 Like

Thanks for double checking and for the feedback @lwshang. Somehow I’m glad to hear the issue might not be on my side. I hope Jetbrains will have a look at the issue someday. If I ever figure out something will update the thread accordingly.

We just releases ic-cdk-macros v0.8.1 which remove the global state in macros. We expect this version can work well with Intellij IDEs.

Please have a try and see if it works.

Credit to @AdamS who fix the issue.

1 Like

Thanks a lot @lwshang and @AdamS, unfortunatelly, same error.

Looks like Jetbrains really don’t like me having multiple canisters within the same workspace that declares the same end point functions.

// console/lib.rs
#[query]
fn version() -> String {
    env!("CARGO_PKG_VERSION").to_string()
}

// satellite/lib.rs
#[query]
fn version() -> String {
    env!("CARGO_PKG_VERSION").to_string()
}

// etc.


Don’t know exactly what was the issue but, upgrading to last candid crate v0.9.11 solves the issue in my IDE.

2 Likes