RustRover 2024.3 Help

Quick start guide

New to RustRover? This guide will help you explore the IDE's workspace and features and try out all the main aspects of the Rust development process.

1. Open or create a Rust project

You have three options to start working on a Rust project.

Create a new Cargo project

  1. Launch RustRover.

    Do one of the following:

    • Click New Project on the Welcome screen.

    • Select File | New | Project from the main menu.

    • Click the Project widget in the main window header and selectProject widget in the main window header and select New Project.

      Create a new project using the Project widget
  2. In the left-hand pane, make sure Rust is selected.

  3. Specify the project location and name.

  4. Specify the location of the Rust toolchain and standard library.

    If the toolchain and standard library are installed, RustRover will detect them automatically. Otherwise, you will be suggested to download Rustup.

    Install Rustup from the New Project wizard
  5. Select the desired project template and click Create.

New project wizard

Open a local Cargo project

  1. In the main menu, go to File | Open. In the file chooser, select the directory containing the root Cargo.toml file (or Cargo.toml itself) and click Open:

    Open a project (not as file)
  2. In the dialog that opens, select Open as project.

    Open a project
  3. When opening the project for the first time, RustRover will prompt you to confirm that you consider it safe.

    Untrusted project

    Click Trust Project if you are certain the project poses no threats and you would like to enable all IDE features. If you have any doubts, select Preview in Safe Mode. For more information, refer to Project security.

Open a project

Clone a repository from VCS

  1. In the main menu, go to File | New | Project from Version Control or click Get from VCS on the Welcome screen.

  2. Specify the repository URL and the destination directory. Click Clone:

    Cloning a repo

2. Explore the workspace and features

RustRover's feature set is designed to simplify the Rust development process. Let's take a closer look at what it has to offer.

Syntax highlighting and code reference

To help you quickly read and understand Rust code, RustRover provides highlighting, inlined hints, macro expansion, quick access to documentation, and more.

Interactive inlay hints

Here are some shortcuts you may find useful:

Action

Shortcut

Expand macro

Alt+Enter

Go to declaration

Ctrl+Click

Get type info

Ctrl+Shift+P

Quick documentation

Ctrl+Q

Quick definition

Ctrl+Shift+I

For more information, refer to Code reference information.

Code analysis and error reporting

To help you fight errors and inconsistencies in code, RustRover offers built-in inspections and integrates with external linters.

For a summary of all detected problems, use the Inspections widget in the upper-right corner of the editor. To see the details, click the widget and refer to the Problems tool window (or select View | Tool Windows | Problems):

Code analysis results: Problems tool window and Inspections widget

Inspections

Inspections run on the fly for all files currently open in the editor. You can also run them manually for a larger scope. To view inspection results, use the Problems tool window (View | Tool Windows | Problems).

RustRover will suggest quick-fixes and intentions where possible. Quick fixes are marked with a red bulb (Quick fix button) and address errors. Intentions are marked with a yellow bulb (Intention button) and suggest possible enhancements and optimizations.

Apply a quick-fix/intention

If an inspection has detected a problem in your code, you can quickly apply a fix in the editor. Place the caret at the highlighted piece of code and press Alt+Enter.

Applying a quick-fix in the editor

    For more information, refer to Code inspections.

    External linters

    Additionally, you can verify your code by running an external linterCargo Check or Clippy.

    Check external linter settings

    To check which linter is enabled and whether it runs on the fly, hover over the linter widget in the status bar:

    External linter widget: Cargo Check on-the-fly analysis is turned off

    To make changes, click the widget. It will open external linter settings.

      Run external linter

      Before proceeding, check whether on-the-fly analysis is turned on or off.

      • If on-the-fly analysis is turned on, you don't need to trigger the linter – it is already running in the background.

      • If on-the-fly analysis is turned off, to call the linter, open the Cargo tool window (View | Tool Windows | Cargo) and click the Run External Linter icon.

        Running an external linter

      Information about detected issues will appear in the Problems tool window, together with inspection results.

      For more information, refer to External linters.

      Formatting

      You can easily format your code using either the IDE's built-in formatter (enabled by default) or Rustfmt.

      Enable (or disable) Rustfmt instead of the built-in formatter

      1. Open settings by pressing Ctrl+Alt+S and navigate to Rust | Rustfmt.

      2. To enable Rustfmt, set the Use Rustfmt instead of built-in formatter checkbox. To disable Rustfmt, clear the checkbox.

        Enabling rustfmt instead of the build-in formatter
      3. Click OK to apply the changes.

      Reformat a file

      1. Open the file you want to reformat in the editor.

      2. Press Ctrl+Alt+Shift+L or select Code | Reformat File.

      3. In the Reformat File dialog, select additional options if necessary and click Run.

        Reformat file dialog

      For more information, refer to Built-in formatter and Rustfmt.

      The Cargo tool window

      The Cargo tool windowCargo tool window is designed to help you with Cargo tasks. By default, it is pinned to the tool windows bar. You can show or hide it by clicking the window indicator on the sidebar the Rust icon (alternatively, select View | Tool Windows | Cargo from the main menu).

      Cargo tool window

      Use the top panel to:

      For more information, refer to Cargo tool window.

      Sharing code in Playground

      You can share your code in Rust Playground without leaving the editor.

      Share in Playground

      1. Select the code fragment you'd like to share (otherwise, the IDE will copy the whole file).

      2. Right-click and choose Rust | Share in Playground.

      RustRover will create a GitHub Gist and display a notification popup with a link to the playground.

      Sharing code in Playground

      3. Build and run

      Use the Build action to compile your code and Run to execute it. There are several ways to perform these actions:

      Build/run Rust code

      • To build or run a particular target, open the Cargo tool window (View | Tool Windows | Cargo) and double-click the target.

        Running a target from Cargo tool window
      • To run from a particular entry point, locate it in the editor, click Execute button in the gutter, and select Run:

        Run from the gutter menu
      • To run a particular file or module, open the Project view, right-click the necessary file or module, and select Run:

        Run file from the context menu in Project view
      • If you want to build or run code using a predefined configuration (with custom parameters and settings), select it in the switcher on the main toolbar and:

        • click Build button to build (Ctrl+F9)

        • click Execute button to run (Shift+F10)

        Build icon on the main toolbar
      • You can always build/run using a Cargo command.

      For more information, refer to Building and running.

      4. Debug

      RustRover provides a full-fledged debugger – with breakpoints, variable monitoring, stepping, memory and disassembly views, and other handy features.

      Start a debug session

      • To start debugging from a particular entry point, locate it in the editor, click Run icon in the gutter, and select Debug:

        Debug gutter option
      • To debug code using a predefined configuration (with custom parameters and settings), select it in the configuration switcher on the main toolbar and click Run icon:

        Initiating debug from the toolbar
      • You can always start a debug session by running a Cargo command.

      For more information, refer to Start the debugger session.

      Learn how to perform basic debugging actions from these guides:

      Debug session

      For more information, refer to the Debug section.

      5. Test

      You will likely support your code with tests, doctests, and/or benchmarks. Here are a few quick ways to run them:

      Run test(s), doctest(s), or benchmark(s)

      • To run a single test or doctest, open it in the editor, click Run icon in the gutter, and select Run:

        Running a test using the gutter icon
      • To run a test/benchmark target, open the Cargo tool window (View | Tool Windows | Cargo) and double-click the target:

        Running a target from Cargo tool window
      • You can always run tests using a Cargo command.

      The Run tool window will open, automatically displaying the results:

      Test runner window

      For more information, refer to the Test section.

      6. Run with coverage

      RustRover allows you to explore code coverage statistics.

      Run with Code Coverage

      To get code coverage statistics, do one of the following:

      • Locate the desired entry point, click Execute button in the gutter, and select Run with Coverage:

        Running with coverage from Project view
      • Locate the necessary file in Project view, right-click, and select Run with Coverage:

        Running with coverage using gutter menu
      • If you want to run a predefined configuration (with custom parameters and settings), select it in the switcher on the main toolbar, then press Run icon and select Run with Coverage:

        Running a configuration with coverage

      The Coverage tool window (View | Tool Windows | Coverage) will open, automatically displaying the results:

      Coverage tool window

      For more information, refer to Code coverage.

      Tune RustRover settings

      You can customize RustRover functionality to match your own needs. Here are some of the available customizations:

      Last modified: 30 September 2024