RustRover 2024.1 Help

Support for conditional compilation

RustRover includes smart support for conditional compilation. It excludes disabled code blocks from code analysis and name resolution, making it unreachable for inspections, refactorings, and other IDE features that are normally turned on. The conditionally disabled code itself appears greyed-out.

The IDE provides a dedicated UI for enabling/disabling Cargo workspace features. It also allows you to specify the target architecture, automatically filtering the appropriate workspace features.

Toggling Cargo workspace features manually

You can manually enable/disable Cargo workspace features.

Enable/disable a single feature

  • Locate the desired feature in Cargo.toml or in the sources and set/clear the corresponding checkbox in the gutter:

    Toggling a specific Cargo feature: from Cargo.toml and from the sources

When you toggle features, RustRover checks the new state with several inspections. For example, if a feature you use in code is missing from workspace dependencies, the IDE will warn you and suggest a quick fix. It will also help you eliminate cyclic dependencies.

Completion will still be available for disabled items:

Completion for cfg-disabled item

Using a conditionally disabled item results in an error, and RustRover suggests a quick fix to enable the corresponding feature:

Enable required feature using a quick fix

Target architecture

If you’re writing platform-specific code and using configuration options (such as target_arch, target_os, target_env, and so on), RustRover can help you switch context in just one click.

Select a target architecture

Do one of the following:

  • Click the the Settings icon icon in the gutter next to the condition and select the desired triple:

    Target architecture switcher in the gutter
  • Locate the dedicated switcher in the bottom right corner of the status bar and use it to select the target architecture:

    Target architecture switcher
Last modified: 26 May 2024