RustRover 2023.3 Help

Code completion

Auto-completion for your Rust code works as you type, and you can also call it manually from Code | Code Completion on the main menu.

For example, completion is available for attributes and elements inside #[derive], including standard library traits:

Completion for inside #[derive]

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

Completion for macro calls

Note that completion is available in doctest comments as well:

Completion in doctest comments


RustRover takes care of out-of-scope items: if you select such an item from the completion list, the corresponding use declaration will be inserted automatically. You can tune auto-import settings in Settings | Editor | General | Auto Import | Rust.

Auto-import when using completion

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.

Disable completion and auto-import for certain items

  1. Navigate to Settings | Editor | General | Auto Import | Rust.

  2. 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.

    Completion in doctest comments

    Note that exclusion settings are ignored for items already imported with a use declaration.

ML completion

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.

ML completion settings

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

Enabling the ML completion markers
ML completion ranking example

Postfix completion

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 a assert_eq! invocation:

Postfix completion

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

Rust postfix templates

To add a custom template, click the Add button and select Rust:

Create custom postfix templates

  1. Press Control+Alt+S to open the IDE settings and then select Editor | General | Postfix Completion.

  2. Click the Add button (the Add button) on the toolbar and select Rust.

    Adding a postfix template
  3. Specify Key, a combination of symbols that will invoke the template.

  4. 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.

Last modified: 13 November 2023