IntelliJ Rust and compile errors?


Anybody use IntelliJ Rust plugin?

I tried it with CLion, where cargo build called from CMakeLists.txt,
and it for some reason do not allow jump from rustc compile errors
in compile log window to source code.

I also tried Android Studio + IntelliJ Rust plugin,
where cargo build called from gradle script, and IDE also does not allow
jump from compile error to source code location for rust,

I missed something, or for some reason this basic feature to hard to implement for any Jetbrains IDE?


Hi @davemilter!

IntelliJ Rust can only handle cargo commands invoked directly, not via an intermediate build system.

You need to create a Cargo command run configuration, or invoke Run Cargo command action via Ctrl+Shift+A .

You don’t need Gradle or CMake to use Rust with CLion or Android Studio.


Hi @matklad! Thank you for answer.

I tried in Android Studio.
I pressed Ctrl+Shift+A, choose Run Cargo command,
and choose check.

But nothing changed in compare with ctrl+f9, yes now only cargo check run,
but I still can not jump from cargo check errors to source code.
Am I missed something?

I do. I used shared library on Rust from C++ and from Java respectively.


Here’s how it looks for me:

Errors are clickable and Ctrl+Alt+Up/Down can be used to cycle through them.

Are paths not resolved for you? Are you using a recent nightly of Rust?


Thanks again @matklad!

Knowledge that it works for some simple cases force me to dig into.
I tried this one project:
(Note: my real project is far more complex, but I started by copying and modifying this one).

So it looks like workspace is not supported yet?

I open android-example alone, and all looks good:

then I open this project as part workspace,
and no jump to errors at all:

As can you see path android-example/src/ is not underlining anymore.

And slso I got crash of Rust plugin after single project -> workspace switch,
and studio suggest to disable rust plugin.

I used recent nightly as default toolchain - rustc 1.25.0-nightly (0f9c78475 2018-01-17).


I would guess that the nightly version of Cargo is to blame: it recently changed the way it invokes the compiler, so the paths are a bit different for packages inside the workspace. This will soon be fixed on IntelliJ Rust side.


beta version also cause the same buggy behaviour,
but stable works .