CLion 2018.2 Help

Rust Support

CLion supports the Rust programming language via the IntelliJ Rust plugin, compatible with all IntelliJ-based IDEs. In addition to basic functionality, the CLion's implementation enables you to use the Cargo build system and debug Rust applications.

Starting a Rust project in CLion:

  1. Install the IntelliJ Rust plugin either directly from the Plugin Repository webpage or right from CLion: go to Settings / Preferences | Plugins, click Browse repositories and type Rust in the search field, then click Install in the plugin description dialog.
  2. Install the Rust package using rustup.rs or other installation options.
  3. Start a new project (File | New Project) and choose Rust in the list of available configurations. In the New Project dialog, provide the paths to the toolchain and the standard library (which can be downloaded via rustup right from the wizard):
    New Rust project in CLion

Working with Rust code

As mentioned above, the IntelliJ Rust plugin is being actively developed, and new features come with every version. Currently, the plugin's capabilities include:

  • Smart editing, for instance, syntax highlighting, code formatting and code folding.
  • On-the-fly code analysis:
    On-the-fly analysis for Rust code
  • Navigation actions, e.g. Find Usage, Go to Class, Go to Super, and File Structure View.
  • Code generation and refactoring options.
  • Quick Documentation popup (Ctrl+Q), including documentation for library functions:
    Quick documentation for Rust code

Running and debugging

To build, run and debug your Rust code, create a new Run/Debug configuration: in the Run | Edit Configurations dialog, press plus and choose Cargo Command from the drop-down list. Then specify the settings for your Cargo Command configuration:

Cargo run/debug configuration

Now CLion's debug features (breakpoints, variable monitor, stepping, and others) are available for your Rust application:

Last modified: 16 June 2018