IntelliJ Rust: Updates For the 2022.2 Release Cycle
In this release cycle, we’ve enabled a new approach for detecting changes in configuration files, as well as a new way to reload project models. We’ve improved performance and implemented various type inference improvements.
IntelliJ Rust now highlights outdated or missing dependencies in
Cargo.toml. The plugin can convert JSON to structs via copy-paste.
There are plenty of other features and improvements – to learn about them all, read the detailed description below.
Project model reloading
In v2022.2, we’ve improved the way IntelliJ Rust updates the project model.
The plugin now detects changes in config files even if they are not saved to disk. This change should make project model reloading more predictable.
IntelliJ Rust now also takes into account changes in Cargo config, the toolchain file and build scripts.
After you’ve changed configuration files, you will now see the floating Load Cargo Changes button. Click on the button, and the IDE will load changes to make your project work correctly.
You can change the settings for project model reloading in Preferences / Settings | Build, Execution, Deployment | Build Tools.
By default, the Reload project after changes in the build scripts checkbox is ticked, and the External changes option is selected. This means that the project model will be reloaded automatically only for external changes (for example, when you get updated files from version control). For any changes made in the IDE, you’ll be offered the Load Cargo Changes button, which allows you to load changes manually.
If you select the Any changes option, the project model will be updated automatically for all changes.
Note that Cargo settings have been moved to Preferences / Settings | Build, Execution, Deployment | Build Tools | Cargo for consistency with other settings for build tools.
Performance improvements for macro calls
We stopped doing some unnecessary cache invalidations. As a result, when you type in macro calls, completion and highlighting should now work faster.
Type inference improvements
In this release cycle, we’ve implemented various fixes and improvements for type inference:
- We’ve implemented unsized coercions in the type inference engine. This fixes false-positive errors like type mismatch between
- We’ve fixed the inference of closure parameter types when closure is assigned to a variable and parameter types are inferred after the assignment.
- We’ve fixed the usage of the
?operator with the
Trytrait. The unstable
Trytrait was moved to
core::ops::try_trait::Tryand its associated types were renamed. This has fixed a number of issues. For instance, now the
?operator works for
- Looping over a type parameter implementing the
Iteratortrait has been fixed and now works as expected.
- The recently added unstable
Destructtrait is now derived for all types.
- The plugin now considers negative
implwhen inferring types.
- Type inference should now work faster thanks to changes in how common type inference cases are handled.
Compiler errors detection
IntelliJ Rust now detects more compiler errors:
- An attempt was made to import an item whereas an
extern cratewith this name has already been imported (E0254).
- The name chosen for an external crate conflicts with another external crate that has been imported into the current module (E0259).
- The name for an item declaration conflicts with an external crate’s name (E0260).
selfkeyword cannot appear alone as the last segment in a use declaration (E0429).
selfimport appears more than once in the list (E0430).
- An invalid
selfimport was made (E0431).
- Visibility is restricted to a module which isn’t an ancestor of the current item (E0742).
Also, detection of duplicate definitions has been improved.
Support for #![recursion_limit] in name resolution
IntelliJ Rust now takes the
#![recursion_limit] attribute into account, which controls macro expansion depth. Previously, the plugin used the default value for the recursion limit, which was 128 steps. But some macros require more steps, and this fix allows expanding them.
If you don’t need macros to expand fully, you can adjust the Maximum recursion limit for macro expansion setting.
Inspections for dependencies in Cargo.toml
We’ve enabled by default two inspections for dependencies in
Cargo.toml: Invalid crate version and New crate version available.
The Invalid crate version inspection detects dependency crates with invalid versions in
The New crate version available inspection informs you that a newer version of a crate is available. There’s also a quick-fix to update the crate version that is available from the inspection popup. You can see all available quick-fixes by pressing ⌥↩ (Alt+Enter).
You can control the inspection settings in Preferences / Settings | Editor | Inspections | Rust. Here you can disable inspections, change the severity level for a particular inspection (displayed by icons in the IDE), or choose how the relevant code is highlighted in the editor.
Inspections for unused_must_use and clippy::double_must_use
We now have inspections and quick-fixes for:
unused_must_uselint that detects unused results of a type flagged as
clippy::double_must_uselint that checks for a
#[must_use]attribute without further information on functions and methods that return a type already marked as
Convert JSON to Rust types via copy-paste
When you copy JSON data and paste it in the editor, the IDE suggests converting it to the struct type. All of the necessary struct field tags are generated and added automatically.
We’d like to thank Jakub Beránek, who implemented the JSON-to-struct conversion feature during the past few releases.
Rename refactoring for metavariables in macros
The Rename refactoring now works for metavariables in macros.
Highlight URLs in string literals
URLs in string literals are now highlighted when you hover over them, and you can open them in a browser. To open a link press ⌘ (Ctrl) and click a link.
If the Emulate terminal in output console option is enabled, the proper terminal is now used in the Run tab. This option also now works on Windows.
You can enable the Emulate terminal in output console option in the Run configuration settings.
As usual, a big thank you goes to the external contributors who have helped us in this release cycle:
That’s it for the most recent updates in the IntelliJ Rust plugin. Tell us what you think about our new features! Write a comment here, ping us on Twitter, or file an issue in the plugin’s issue tracker. Thank you!
Your Rust team
The Drive to Develop
Subscribe to Blog updates
Thanks, we've got you!