Rust plugin update: language support improvements, new quick-fixes, improved debugger and more


CLion 2018.2 was released just recently. Along with the release, the Rust plugin has had an update! In this blog post, we’d like to highlight some of the main improvements in the plugin.

However, before we do that, let me briefly remind you about the current state of the Rust plugin:

  • It’s available in all our IntelliJ-based IDEs.
  • It relies on the Cargo build system, and CLion is no exception here!
  • The debugging feature for Rust code is currently only available in CLion.

Here we listed earlier the features in the Rust plugin. What’s new for Rust with the 2018.2 update?

Language support

There is a set of language support improvements. We’ll highlight the most important:

  • Pattern-matching on references got some attention in the language (RFC 2005), and now it is supported properly in the IntelliJ Rust plugin, which means the types are inferred correctly.
  • The expansion of declarative macros guarantees that you can now get better code insight when using macros. For example, the completion works:
    Macro Expansion
    The best use of it is for error handling via error-chain crate based on macros.

    Keep in mind its limitations – if the impl block is generated with the macro on its own, then such completion won’t work as the IDE currently is not aware of its expansion.

New and improved quick-fixes

A whole new set of quick-fixes were implemented to make your Rust code more accurate and save you time while coding. The first group of quick-fixes is related to the type-check errors. For example, when a manual cast is missing in the code (as an implicit cast is not allowed for primitive types) you can generate a proper cast with Alt+Enter: Numeric type cast

As CLion (and the other IntelliJ-based IDEs with the Rust plugin) is aware of the traits available for the type, it can suggest type conversions to fix type checking errors in the code using the proper trait. An example of how this could be used is if a string was used by mistake, but the FromStr trait is present for the type, then a quick-fix invoked with Alt+Enter can generate a proper conversion:
String trait usage

By the way, while we are on the topic of strings, as you know String and &str are not the same in Rust. The main difference is in the object ownership – &str is just a reference to some location in the memory, it doesn’t own it. So what if a &str is passed where the String is needed? There are several options actually, and all of them are available in the quick-fix menu:
String convertion

You can also convert a struct to reference to this struct where needed:
Reference quick-fix

There are even more quick-fixes available for the type checks, thanks to oleg-semenov’s incredible contribution to the IntelliJ Rust plugin!

As for the other code analysis checks, an unresolved reference check with the Auto Import quick-fix can save you time if you have tried to start using something before importing it:
Unresolved reference

Besides, when you implement missing members via a quick-fix, the IntelliJ Rust plugin will correctly substitute a generic type parameter and lifetimes for you! How cool is that?Implement missing members

Quick documentation update

Quick Documentation (Ctrl+Q on Linux/Windows, F1/^J on macOS) shows the documentation for the symbol at the caret. And now it includes the links to for the standard library items:
Quick Documentation

Pretty-printers in debugger

CLion comes with the Rust debugger included. You know that! And now it loads the default Rust pretty-printers for you, so that you now have a nice view of the values of the default types like strings or vectors.

Better project view

The Cargo tool window (View | Toolwindows | Cargo) now shows all the workspace members and targets:
Cargo toolwindow
It simplifies the way to run targets – you can now simply click on them in this tool window. You can also refresh your Cargo project, run clippy or a Cargo command, and attach or detach a Cargo project to the workspace.

There are some important enhancements to the editor’s performance, so that the typing in Rust feels smoother and the editor is more responsive. And there is even more! Check out the collection of recent release notes here.

Wanna give new features a try? Get CLion (or any other IntelliJ-based IDE) with the Rust plugin now!

Download CLion

Your Rust Team

The Drive to Develop

Comments below can no longer be edited.

14 Responses to Rust plugin update: language support improvements, new quick-fixes, improved debugger and more

  1. Avatar

    Rafal says:

    August 2, 2018

    This looks great, please continue for rust support, this will speed up adoption for this great language!

  2. Avatar

    Linker Nick says:

    August 3, 2018

    Thank you, this is awesome!

  3. Avatar

    Denys Vitali says:

    August 3, 2018

    Is a Rust IDE planned for the future?

    JetBrains makes pretty good IDEs, it would be pretty awesome if you guys decided to start an independent IDE like GoLand, but specifically made for Rust (Rustland?)

    Whilst the Rust plugin for IntelliJ / CLion is already pretty good, feature-wise (compared to other plugins for other editors), it is still tremendously slow 🙁

    • Anastasia Kazakova

      Anastasia Kazakova says:

      August 4, 2018

      No such plans for now. Also, I don’t see how the stand-alone IDE will help with the performance? I would recommend you to report performance issues to the Rust team tracker, so that we take a look and improve.

      • Avatar

        Nicholas Sterling says:

        October 10, 2018

        I’m confused. Anyone doing Rust work is likely to have to deal with C/C++ code at some point; why wouldn’t you want one IDE to handle the whole mess? I don’t get why separating Rust IDE support into a separate product wouldn’t be a BAD thing.

        • Anastasia Kazakova

          Anastasia Kazakova says:

          October 11, 2018

          C/C++ is indeed a very natural companion for Rust, that’s why Rust plugin is available in CLion. However, CLion has much bigger functionality which is probably not need for Rust developers. But for now we still don’t plan to have a separate Rust IDE. We are fine with the plugin setup available now.

  4. Avatar

    Just Me says:

    August 9, 2018

    When will it be possible to create Modules in CLion just like in Intellij years? This is the only reason I use intellij when I don’t need a debugger.

    • Anastasia Kazakova

      Anastasia Kazakova says:

      August 9, 2018

      Could you please elaborate on the use case here?

  5. Avatar

    Xymist says:

    August 9, 2018

    I’m primarily a Ruby developer, so I use RubyMine rather than CLion; is there a plan/timeline for adding the debugger support to IDEs other than CLion? Otherwise this works very well.

    • Anastasia Kazakova

      Anastasia Kazakova says:

      August 9, 2018

      No such plans at least for now.

  6. Avatar

    Fabio Rafael da Rosa says:

    August 9, 2018

    Does Clion still enforces the existence of cmake files in Rust projects ?

    • Anastasia Kazakova

      Anastasia Kazakova says:

      August 9, 2018

      No, it works with Cargo starting with 2018.1 version

  7. Avatar

    appcypher says:

    January 11, 2019

    This plugin is flipping awesome. Keep up the good work!

  8. Avatar

    allwefantasy says:

    October 18, 2019

    Thank you, this is awesome!

Discover more