Code completion
Auto-completion for your Rust code works as you type. You can also call it manually by pressing CtrlSpace.
For example, completion is available for attributes and elements inside #[derive]
, including standard library traits:

For popular Rust crates, you will receive suggestions even if the crate hasn’t been added to dependencies:

Completion also works inside macro calls. The plugin knows the resulting macro substitution and suggests only the applicable items:

Note that completion is available in doctest comments as well:

RustRover takes care of out-of-scope items. If you select an out-of-scope item from the completion list or paste code containing such items, RustRover will automatically insert the missing use
declarations. This behavior is enabled by default, however you can always disable it in Settings | Editor | General | Auto Import (Rust section).

Optionally, you can turn on automatic import on the fly. This way, RustRover will add missing use
declarations as you type (unless there are several possible options).
Press CtrlAlt0S to open settings and then select Editor | General | Auto Import.
In the Rust section, select the Add unambiguous imports on the fly checkbox, and apply the changes.
You may want to exclude certain items from completion lists and make sure they never get auto-imported. For example, you may want to exclude functions and traits that are re-exported in irrelevant crates – this way, only original ones will be suggested.
Navigate to Settings | Editor | General | Auto Import and locate the Rust section.
In the table, list the items that you want to exclude from completion and auto-import.
The following rules apply:
Specify each path just as you would in a
use
declaration.Add
::*
to a path if you want to disable auto-import for all items whose paths include the given prefix.When excluding traits, use the Apply to dropdown menu to specify whether you want to disable auto-import only for trait methods or for the trait name too.
Note that exclusion settings are ignored for items already imported with a
use
declaration.tip
By default, the list contains
Borrow
andBorrowMute
items: auto-importing them is rarely reasonable and may change behaviour in unwanted ways. You can remove these items from the list if needed.
Pasting code to an .rs
file may require you to mention additional dependencies in Cargo.toml
. RustRover takes care of that. By default, each time you paste code that mentions a new crate, RustRover displays a dialog asking you to confirm the list of crates to be added.
warning
This feature works for most popular crates. With other crates, you will have to add the dependencies manually.

Do one of the following:
Once the Add Crates confirmation dialog appears, select Always Add if you want the crates to be added silently or Never Add if you don't want RustRover to ever suggest any new dependencies.
In the Settings dialog (CtrlAlt0S) , go to Editor | General | Auto Import, locate the Rust section, and select the desired value in the Add crate dependencies on paste dropdown: Always, Never, or Ask.
Machine learning assisted completion is enabled by default. The suggestions are sorted by their relevance based on the rules learned from data gathered anonymously during the IDE's Early Access Program. Note that your source code is never being collected, only the information about your interactions with the code completion UI.
If you prefer to disable the ML completion feature, clear the corresponding checkbox in Settings | Editor | General | Code Completion.

Set the Mark position changes in the completion popup checkbox to view the elements that were reordered to the ML data:


Postfix completion helps you reduce backward caret jumps as you type. You can transform an already-typed expression into a different one based on a postfix you type after the dot.
For example, type .assert
after an expression (or select it from the completion suggestion list) to insert an assert_eq!
invocation:

You can check and adjust the list of postfix templates in Settings | Editor | General | Postfix Completion | Rust:

To add a custom template, click and select Rust:
Press CtrlAlt0S to open settings and then select Editor | General | Postfix Completion.
Click the Add button (
) on the toolbar and select Rust.
In the Create New Template dialog that opens, specify Key, a combination of symbols after the dot that will invoke the template.
Select which expression types the new template will be applicable to, and type the target expression in the following format:
$EXPR$ <target_expression>
, for example,$EXPR$ =!null
.
Thanks for your feedback!