The workspace (if any), the packages, and the targets, are organized into Cargo projects. A Cargo project is defined by a Cargo.toml file and the sources contained in the corresponding folder. Identifying Cargo projects is crucial for code insight and navigation.
More often than not, the first time you open a project, RustRover will identify all Cargo projects automatically. However, in some cases (for example, if there is a Cargo.toml file outside the Cargo workspace), it may be unable to detect all of them. If you cannot find some of your Cargo projects in the Cargo tool window, consider attaching them manually.
Attach a Cargo project
Do one of the following:
Right-click the Cargo.toml file in the project tree and select Attach Cargo Project from the context menu.
In the Cargo tool window (View | Tool Windows | Cargo), click the icon and select the necessary Cargo.toml file or the directory containing it.
If the project has an uncommon structure, the first time you open it, RustRover will display a dialog asking you to choose the Cargo projects to attach.
note
Note that the projects marked as workspace members in the Cargo configuration are greyed out and cannot be interacted with.
tip
This is the default behavior for all newly opened projects. If needed, you can disable it in Settings | Advanced settings: locate the Rust section and clear the Show Attach Cargo Projects dialog each time a new project is opened checkbox.
As you work in the editor, RustRover checks whether the files you open belong to some Cargo project. If not, you will see a banner suggesting to associate the file with a Cargo project.
When you click Attach Cargo.toml, RustRover will try to identify the corresponding Cargo project. If successful, it will automatically attach the project and reflect it in the Cargo tool window. Otherwise, you'll be prompted to manually select the necessary Cargo.toml file from the file chooser.
tip
If your project contains multiple files that are not associated with a Cargo project, go to Settings | Advanced settings, locate the Rust section, and enable the Show Attach Cargo Projects dialog each time an unattached file is opened setting. After that, the Attach Cargo Projects dialog will appear when you open an unattached Cargo.toml file. This allows you to review the project structure and select which Cargo projects you want to attach to the project model.
Detach a Cargo project
In the Cargo tool window (View | Tool Windows | Cargo), select the Cargo project you want to detach and click the icon.