IntelliJ / Rust plugin equiv of // @ts-ignore

In *.ts files, we can do // @ts-ignore to say: ignore compiler warnings on next line, everything will be fine.

I'm dealing with some hand written wasm_bindgen / ffi code. It compiles file, but IntelliJ / Rust plugin is giving me little red squiggly lines (due to the plugin not properly parsing the wasm_bindgen / ffi declarations).

Is there a similar way in IntelliJ / Rust plugin to say "ignore warnings / what looks like compiler errors in the next section of code" ?

If it compiles fine but errors are displayed in the editor, this is likely an error with your editor configuration or caches. In IntelliJ, you try to use File > Invalidate Caches and see if that helps.

I don't fully understand the tsignore idea - Rust is a statically-typed language and you can't just ignore an error. If you mean to suppress errors in your editor, that wouldn't be useful (in almost all cases) as these should always represent what cargo check outputs, in some form or another.

The IDE in this case (as I understand it) it trying to interpret code independently or semi-independently of the compiler, and sometimes gets it wrong.

Aside from that, many of rustcs warnings, and even some of it's errors, are in fact lints which you can adjust the severity of (including silencing, or ignoring, them). One could also imagine doing that (for compiler generated warnings) at the IDE level.

The issue here, which @quinedot stated and I'm expanding on is that IntelliJ / Rust plugin does it's own parsing, not using the rustc compiler.

Thus, for some code, like:

#[wasm_bindgen::prelude::wasm_bindgen]
extern "C" {
    pub type Msg_Inner;

you can get situations where it compiles fined by rustc, but due to limited handling of macros by IntelliJ / Rust plugin, it looks like an error to the plugin (despite being 100% valid Rust code).

You can allow(warnings), but I highly recommend not to do this. It’s not related to plugins, only the compiler.

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.