Rust plugin for the IntelliJ Platform

Related tags

IDEs rust intellij
Overview

Rust plugin for the IntelliJ Platform

official JetBrains project Join the chat at https://gitter.im/intellij-rust/intellij-rust JetBrains plugins JetBrains plugins

Build Status
Check Check Status
Stable Stable Build Status
Beta Beta Build Status
Nightly Nightly Build Status

Installation & Usage

Available installation options and features are described on intellij-rust.github.io. All new features are announced in the changelog.

If you want to jump straight in, open Settings > Plugins > Marketplace in your IDE, search for Rust and install the plugin. To open an existing project, use File | Open and point to the directory containing Cargo.toml. For creating projects, use the Rust template. You can find more details in the Quick Start Guide.

Compatible IDEs

The plugin is compatible with all IntelliJ-based IDEs starting from the version 2020.3, with the following differences in the sets of the available features:

Open-source and Educational IDEs* CLion (commercial) IntelliJ IDEA Ultimate, PyCharm Professional, GoLand (commercial) WebStorm, PhpStorm, other commercial IDEs
Language support + + + +
Cargo support + + + +
Code coverage + + + +
Debugger - + +** -
Profiler - + - -
Valgrind Memcheck - + - -
Detecting duplicates - + + +

* IntelliJ IDEA Community Edition, PyCharm Community Edition, PyCharm Edu and IntelliJ IDEA Edu.

** Requires the Native Debugging Support plugin. LLDB only. PyCharm Professional and GoLand support debugging starting from 2021.1

TOML

If you are looking for the TOML plugin, see intellij-toml directory.

Contributing

You're encouraged to contribute to the plugin if you've found any issues or missing functionality that you would want to see. Check out CONTRIBUTING.md to learn how to set up the project and ARCHITECTURE.md to understand the high-level structure of the codebase. If you are not sure where to start, consider the issues tagged with help wanted.

Comments
  • Implement debugger

    Implement debugger

    The work has started: https://github.com/intellij-rust/intellij-rust/tree/fc2cfb8e0fc76984495a34ae6a83cbb37188c699/debugger

    State of the art

    The debugger is officially available in CLion since 2018.1. Note, CLion doesn't support debugging with msvc toolchains, so if you are using Windows, you need:

    • install gnu rust toolchain (rustup install stable-gnu)
    • setup gnu (Cygwin or MinGW) toolchains in CLion (Preferences > Build, Execution, Deployment > Toolchains).

    To debug you just need to:

    • Run debug command via gutter icon 2018-05-28 11 46 26
    • Or create Cargo Command run configurtion
    screen shot 2018-05-28 at 11 50 04 and run debugging via debug action

    2018-05-28 11 52 16

    Old content

    Old content

    If you use CLion and the nightly Cargo, you should be able to Debug Cargo configuration:

    https://zippy.gfycat.com/AcidicMediocreCoati.webm

    A major missing piece is that we don't pass command line arguments to the debuggee yet (this requires some work on the Cargo side of things first).

    Old content 2

    Currently for technical reasons (commit message) debugger is implemented as a separate plugin.

    The current build can be download from TeamCity: Download. It may work with CLion 2016.3.2 and intellij-rust 0.1.0.1611.

    Note that this is super unstable, debugger can invoke any kind of undefined behavior, including, but not limited to, summoning of nasal daemons. Most importantly, rust debugger may (though in theory it should not) break C++ debugging.

    Nonetheless, step into and local variables view more or less work :)

    debugger

    As you can see on the screenshot, at the moment you unfortunately have to create a separate Cargo debug run configuration type (as opposed to the usual Run cargo command). Also, you only can debug binaries now :(

    subsystem::debugger feature 
    opened by matklad 137
  • Contributor License Agreement

    Contributor License Agreement

    To everyone who has contributed code to IntelliJ Rust: we want to make this plugin officially supported by Jet Brains, but to do so, we need contributor license agreements signed by anyone who had added code to the plugin. If you do not wish to sign such a CLA form, let me know so that I can find a way to back out any changes you may have made.

    To sign the CLA, please follow instructions at https://www.jetbrains.com/agreements/cla/. The procedure consists of a couple clicks: no need to scan or print or snail-mail anything. Comment on this issue after signing the CLA so that I can track progress easily.

    The text of CLA can also be found here.

    It's quite possible that due to recent code rewrites, your change may not appear anymore. If that is the case, I only ask that you verify this, so I can take you off of the list of people we need CLAs from.

    Thank you all!

    Q&A:

    Q: Does this mean that IntelliJ Rust is becoming a closed source proprietary project of Jet Brains?

    A: No, IntelliJ Rust plugin will be free, open source and welcoming to contributors. However it is possible that in the future Jet Brains releases a paid product based on the IntelliJ Rust technology.

    Q: What is the purpose of CLA?

    A: This CLA is for your protection as a Contributor as well as the protection of JetBrains and its users; it does not change your rights to use your own Contributions for any other purpose.

    cc:

    • [x] @alexeykudinkin
    • [x] @alexpana
    • [x] @allengeorge
    • [x] @alobb
    • [x] @alygin
    • [x] @andruhon
    • [x] @ashleysommer
    • [x] @bgourlie
    • [x] @CGavrila
    • [x] @chriskrycho
    • [x] @contradictioned
    • [x] @d9n
    • [x] @daschl
    • [x] @Falkenfighter
    • [x] @farodin91
    • [x] @framlog
    • [x] @friedroman
    • [x] @greg-kargin
    • [x] @himikof
    • [x] @HybridEidolon
    • [x] @johnthagen
    • [x] @jonas-schievink
    • [x] @KalitaAlexey
    • [x] @Keats
    • [x] @kumbayo
    • [x] @la10736
    • [x] @LiamClark
    • [x] @Litarvan
    • [x] @madisp
    • [x] @mbStavola
    • [x] @mcarlin
    • [x] @mfarrugi
    • [x] @mitchhentges
    • [x] @mkaput
    • [x] @mrhota
    • [x] @netvl
    • [x] @ninjabear
    • [x] @oistein
    • [x] @pavel-v-chernykh
    • [x] @Shiroy
    • [x] @sirgl
    • [x] @slavam2605
    • [x] @ThoseGrapefruits
    • [x] @tigarmo
    • [x] @tov
    • [x] @Turbo87
    • [x] @Undin
    • [x] @vasily-kirichenko
    • [x] @winger
    • [x] @zjhmale

    Issue template take from https://github.com/jwiegley/use-package/issues/282 :)

    opened by matklad 61
  • What about using WSL Rust?

    What about using WSL Rust?

    Hi. I'm trying to figure out how to use rustc & cargo from my WSL, where I installed rust, and works perfectly. In fact, I don't want to install Rust on Windows.

    https://medium.com/@bgourlie/cross-platform-development-on-windows-is-suddenly-awesome-da863a28fa1e

    E-hard feature subsystem::build & run subsystem::wsl 
    opened by concatime 47
  • Support items generated by proc macros

    Support items generated by proc macros

    For example, let's say I am using the crate derive_builder with the following code snippet:

    #[derive(Clone, Debug, Builder)]
    pub struct MyStruct {
        foo: String
    }
    

    derive_builder generates a new struct named MyStructBuilder. I'd like to have this generated MyStructBuilder struct available as an autocomplete option to make its usage easier.

    meta E-hard subsystem::code insight feature subsystem::macros subsystem::proc-macros 
    opened by shssoichiro 41
  • Support symlinks better

    Support symlinks better

    Resolve all symlinks in packages and targets.

    Also, resolve symlinks before any call of LightDirectoryIndex to use the same virtual files as we use while index creation

    Should fix #2466, but I don't know how to create good tests for this case Fixes #2633

    opened by Undin 40
  • Possible regression in release 127 - rust edition not detected, file not include in module tree

    Possible regression in release 127 - rust edition not detected, file not include in module tree

    Environment

    • IntelliJ Rust plugin version: Release 127 -- also tried 0.3.128.3262-202-nightly
    • Rust toolchain version: 1.45
    • IDE name and version: IntelliJ Community 2020.2 (was also the case on 2020.1)
    • Operating system: Kubuntu Linux 19.10

    Problem description

    After updating the plugin from 126 -> 127 my project had lots of various errors. I have tried reimporting the project, re-loading the Cargo.toml from the "Cargo" menu. In Release 126, I was using the "experimental macro engine" and I didn't have any errors across my project.

    I don't really understand which of the following is a root problem, so I will just post some of the issues to give a picture of what I'm experiencing.

    Edition is not being correctly detected and async keyword is disallowed

    "This feature is only available in Edition 2018"

    image

    Source files are not being included in the module tree

    "File is not included in module tree"

    image

    Modules declared at the top level are not found

    "File not found for module"

    see first screenshot

    The one thing that makes this project different is that it is using rust-protobuf to do codegen and is including the generated code at the top of main. This means the project not only has a build.rs, but also an include! macro in main.rs.

    I downgraded the plugin to 126 in 2020.1 and the project started building properly again. I can't use plugin 126 in 2020.2. Is there a way I can get a build (or build myself) a version of 126 that I can use in 2020.2 while we work this out?

    I did try suggestions in #3628 and #4907, but have not been able to find a resolution.

    Thanks for your help, and thanks for an awesome plugin. :)

    Steps to reproduce

    Source code for project is not open source, so this may be difficult.

    bug 
    opened by clintfred 38
  • COMP: add all remaining arms match postfix template

    COMP: add all remaining arms match postfix template

    This PR changes match postfix template to generate all match arms instead of just a single wildcard.

    Currently, no template is used, the caret is just moved after the left brace of the first arm. Should there be some template to rename things from the generated arms? If yes, what should it rename?

    Fixes https://github.com/intellij-rust/intellij-rust/issues/6630 Fixes https://github.com/intellij-rust/intellij-rust/issues/4727

    changelog: match postfix template now generates all missing match arms by default.

    feature 
    opened by Kobzol 37
  • INT?: Implement trait methods and type aliases

    INT?: Implement trait methods and type aliases

    This PR extends Implement members functionality.

    1. Added automatic implementation of type aliases (with defaulting type ())
    2. Implement members quick fix now shows a chooser dialog to choose members to implement
    3. Ctrl+I (implement members code insight feature) is now available

    Example of chooser dialog: image

    Example (when all members were chosen):

    #![feature(associated_type_defaults)]
    
    trait Foo {
        type Type1 = i32;
        type Type2;
        type Type3;
        fn foo();
        fn bar();
        fn baz() {}
    }
    
    struct Bar;
    
    impl Foo for Bar {
        type Type2 = ();
        type Type3 = ();
    
        fn foo() {
            unimplemented!()
        }
    
        fn bar() {
            unimplemented!()
        }
    }
    

    Note: I commented out one test, because now quick fix does not automatically generate all members, only after dialog choosing. I don't know how to write a new version of test.

    opened by slavam2605 35
  • REF: add basic implementation of change signature refactoring

    REF: add basic implementation of change signature refactoring

    This PR adds the Change signature refactoring.

    change-signature

    The current implementation has basic functionality.

    • ~How should the user be able to enter the name and type of parameters? I suggest that we use RsPat for name and Ty or RsTypeReference for types instead of plain strings, so that after the user enters something, we try to parse it and if it fails, we will not allow the dialog to proceed.~
    • ~Currently, if a new parameter is added, it will not be filled with a default value at call sites, so that the user will not forget to update the call sites. This mirrors the behaviour of Kotlin.~
    • ~Should the dialog offer things like async, unsafe, extern or variadic args? If yes, we need to let the user enter any possible value for these attributes. I think that it's worth to do it only if we can actually refactor something after changing them. Maybe removing/adding await/unsafe from call sites?~
    • ~Originally I wanted to unify the Change signature and Extract function UI (and some data structures), but I realized that they actually differ quite a lot and it would complicate the code too much I think. I checked the Kotlin plugin and it has two different dialogs for these refactorings, so I think that it's ok.~
    • ~I wanted to move all surrounding whitespace and comments when a parameter is moved from one place to another, but I'm having a difficulty making it work. The commented code in insertItemWithComma didn't work, basically if I try to do something like this:~
    val inserted = parent.addBefore(<some whitespace>, anchor)
    

    ~the inserted will contain anchor instead of the inserted whitespace. This breaks copying of successive whitespace and comment elements, which I tried to do in a loop. Any hints of what might be wrong here?~

    I'm not a huge fan of the signature config being mutable, but it makes UI and test code simpler and it also helps with detection of modified parameters (so I don't have to generate a GUID or something like that for them).

    ~The logic about detecting moved/removed/added parameters is slightly convoluted, it could be probably simplified, but I want to leave that for a final refactoring. It's not as simple as it sounds, as we must detect what parameters were removed, what were added and what were just moved, these operations have different semantics, even if they end up with the same result in the signature (see test move and add parameter and test swap parameters).~

    Fixes: https://github.com/intellij-rust/intellij-rust/issues/4927

    changelog: Add the Change Signature refactoring for functions and methods.

    feature 
    opened by Kobzol 34
  • ANN: add quick fix to add function parameter from function call

    ANN: add quick fix to add function parameter from function call

    This PR adds a quick fix that lets the user add new function parameters to a function from a function call, using the new Change signature refactoring. So far it only works for function and method calls and not tuple struct constructors. The behaviour of the fix is heavily inspired by a similar fix in the Kotlin plugin. add-parameters

    There are two TODOs in the code, which I'm not sure how to resolve:

    • How to name parameters? p0, p1, etc.? Or continue counting from the existing parameter count? Also the fix should probably make sure that it doesn't generate collisions in parameter binding names.
    • How to get the correct type reference from the argument expression type? That is especially important for import to work. I tried to use a type reference fragment, that sort-of works, but it imports the type with a wrong path. I need to somehow get from Ty to RsTypeReference that exists in the context of the target function.

    Related issue: https://github.com/intellij-rust/intellij-rust/issues/6744 Fixes: https://github.com/intellij-rust/intellij-rust/issues/3582

    changelog: Add quick fix to add a parameter to a function from a function call.

    feature 
    opened by Kobzol 33
  • Inline function arguments correctly

    Inline function arguments correctly

    Currently it replaces function parameters with the function arguments. Still need to make sure arguments will be resolved in the same order were they not inlined by creating variables for them before the main inline. Here's a Kotlin example: That's the original file. We'll inline foo()

    var count = 1
    private fun main() {
        val a = foo(bar())
    }
    
    private fun foo(number: Int): Int {
        return number * bar() + number
    }
    
    private fun bar(): Int {
        return count++
    }
    

    The original code should get 2 * 3 + 2 inside foo. My code currently inlines the values directly, like so:

    var count = 1
    private fun main() {
        val a = bar() * bar() + bar()
    }
    
        private fun bar(): Int {
        return count++
    }
    

    Which leads the calculation to be 2 * 3 + 4, because the function will be called an additional time. The correct inline (as shown by Kotlin) is:

    var count = 1
    private fun main() {
        val number = bar()
        val a = number * bar() + number
    }
    
        private fun bar(): Int {
        return count++
    }
    

    Which makes sure number has a single value, assined before any calls for bar() happening inside foo().

    feature 
    opened by SaarYogev 33
  • Cannot infer type with `try` block

    Cannot infer type with `try` block

    Environment

    • IntelliJ Rust plugin version: 0.4.185.5086-223
    • Rust toolchain version: 1.67.0-nightly
    • IDE name and version: CLion 2022.3
    • Operating system: Arch rolling

    Problem description

    With the unstable try_blocks feature, I just take the demonstration code from https://github.com/rust-lang/rust-analyzer/pull/13856, and it doesn't work.

    Screenshot_2023-01-06_19-39-49

    Steps to reproduce

    #![feature(try_blocks)]
    
    fn main() {
        let r = try { 1_u32 };
        match r {
            Ok(a) => (),
            Err(()) => (),
        };
    }
    
    opened by bczhc 0
  • RsMacroArgument should implement PsiLanguageInjectionHost

    RsMacroArgument should implement PsiLanguageInjectionHost

    The pre-requisite for injection availability is the macro must accept a TokenStream.

    This will allow IntelliLang to automatically propose injection of different languages. A typical use case might be injecting the Pomsky language to which I'm adding support in IDEA.

    At the moment I'm implementing my own injection, which is a lot of work.
    So if we can have it in the language itself, it's better.

    cc @Aloso

    feature subsystem::macros 
    opened by lppedd 1
  • Information flow highlighter similar to Flowistry plugin for VisualStudio

    Information flow highlighter similar to Flowistry plugin for VisualStudio

    This plugin has everything I need and more. However there is one thing I really miss - The wonderful Flowistry plugin in Visual Studio and can't seem to find anything similar in Jetbrains. I keep going back to Visual Studio just to use this highlighter. I wish there was something similar for Rust. This will truly make Jetbrains the goto IDE for me.

    opened by breakpointninja 0
  • "Introduce variable/parameter" cannot extract constant from a function call

    Environment

    • IntelliJ Rust plugin version: 0.4.185.5086-223
    • Rust toolchain version: 1.63.0 (4b91a6ea7 2022-08-08) x86_64-pc-windows-msvc
    • IDE name and version: CLion 2022.3.1 (CL-223.8214.51)
    • Operating system: Windows 10 10.0
    • Macro expansion: enabled

    Problem description

    "Introduce variable" or "Introduce parameter" is not able to extract a parameter from a function call if that parameter is a constant.

    Steps to reproduce

    Example code:

    fn get_thing(x: &str) -> Option<String> {
    	return None;
    }
    
    const CONSTANT_STR: &'static str = "ABC";
    
    fn test() {
    	get_thing("abc");
    	get_thing(CONSTANT_STR);
    }
    

    If I place caret inside "abc" and use Introduce Parameter, it correctly suggests "abc" as an option:

    obrazek

    If I place caret inside CONSTANT_STR, it immediately extracts the whole function call:

    obrazek

    bug subsystem::refactoring 
    opened by chylex 0
  • Rust colors don't inherit properly

    Rust colors don't inherit properly

    IntelliJ IDEA 2022.3.1 (Ultimate Edition) Build #IU-223.8214.52, built on December 20, 2022 Runtime version: 17.0.5+1-b653.23 amd64 VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o. Windows 11 10.0 GC: G1 Young Generation, G1 Old Generation Memory: 4096M Cores: 8

    Non-Bundled Plugins: org.rust.lang (0.4.185.5086-223)

    Problem description

    Please check the options in Rust Color scheme - 2 values constantly switch (after syncing options from another JetBrains IDE like WebStorm) to default colors instead of inheriting values from options in the General and Language Defaults color sections (please check the screenshots), looks like their setup differs from the other options, what causes this bug. I have to always switch these options' values manually, which is not comfortable.

    These options are:

    Functions - Function call Functions - Method call

    All other colors in Rust section don't change unexpectedly and work fine.

    Actually, the bug is pretty the same as here (if that could help in any way): https://youtrack.jetbrains.com/issue/PY-58264/Python-colors-dont-inherit-properly

    2023-01-03_235254

    2023-01-03_235307

    Environment

    Steps to reproduce

    Looks like the bug is with Setting Sync option but I'm not 100% sure.

    How to reproduce:

    • I have Settings Sync turned on in WebStorm and IntelliJ.
    • I opened WebStorm and changed the color of Color Scheme - Language Defaults - Predefined symbol.
    • Then I closed WebStorm and opened IntelliJ. Then opened Rust section in Color Scheme, and those 2 options are not inherited again.
    opened by makarichevss 0
Owner
IntelliJ Rust
Umbrella organization for all the projects related to IntelliJ Rust plugin
IntelliJ Rust
Obsidian Plugin: Convert a URL into markdown

Obsidian Plugin: Convert a URL into markdown Transforms a URL to markdown view if the website allows it. Installation Available in the community plugi

Stephen Solka 142 Jan 3, 2023
Rust IDE support for Atom, powered by the Rust Language Server (RLS)

IDE-Rust Rust language support for Atom-IDE, powered by rust-analyzer. Features Auto-completion Diagnostics (errors and warnings from rustc) Document

The Rust Programming Language 239 Dec 14, 2022
rust-analyzer is a modular compiler frontend for the Rust language

rust-analyzer is a modular compiler frontend for the Rust language. It is a part of a larger rls-2.0 effort to create excellent IDE support for Rust.

null 11.2k Jan 8, 2023
Rust language support in Atom - LOOKING FOR MAINTAINER, see #144

Rust language support in Atom Adds syntax highlighting and snippets to Rust files in Atom. Install Install the package language-rust in Atom (Preferen

Andreas Neuhaus 118 Oct 11, 2022
Eclipse Corrosion - Rust edition in Eclipse IDE

Eclipse Corrosion Rust edition and debug in Eclipse IDE Corrosion is a Rust development plugin for the Eclipse IDE, providing a rich edition experienc

Eclipse Foundation 194 Dec 23, 2022
RustDT is an Eclipse based IDE for the Rust programming language:

Project website: http://rustdt.github.io/ As of 2017, RustDT is no longer actively maintained, see this blog post for more information. If you are int

null 351 Aug 20, 2022
Emacs configuration for Rust

Table of Contents Introduction Installation Melpa Manual installation Feature guide Indentation Code formatting Running / testing / compiling code Cli

The Rust Programming Language 919 Jan 4, 2023
Rust development environment for Emacs

Rustic Table of Contents Rustic Intro Installation straight Compilation Faces rustc errors Rustfmt edition 2018 LSP Server Client eglot lsp-mode lsp-e

null 612 Dec 30, 2022
Better Rust/Cargo support for Flycheck

flycheck-rust — Flycheck for Rust This Flycheck extension configures Flycheck automatically for the current Cargo project. Setup Install from MELPA or

Flycheck 112 Sep 21, 2022
Rust IDE

This branch contains the development of a "new ride" that maintain a small impact on the ui library. This is for a few reasons. Can customize the colo

Gustav Jansson 171 Dec 24, 2022
An IDE for Rust

Introduction SolidOak is a simple IDE for Rust. See the website for binary releases. It has the following features: An embedded copy of Neovim as its

Zach Oakes 907 Dec 29, 2022
The official Sublime Text 3 package for the Rust Programming Language

Rust Enhanced About This is a Sublime Text 3 package which supports Rust starting with version 1.0, it makes no attempt at supporting earlier incompat

The Rust Programming Language 704 Jan 7, 2023
Vim configuration for Rust.

rust.vim Description This is a Vim plugin that provides Rust file detection, syntax highlighting, formatting, Syntastic integration, and more. It requ

The Rust Programming Language 3.4k Jan 8, 2023
Rust Cargo command bindings

Vim Cargo Simple vim command bindings to quickly run cargo stuff from vim. Commands Available, mapping with their Cargo equivalant: CargoBench CargoBu

Timon Vonk 52 Dec 24, 2022
Visual Studio extension for Rust

Visual Studio extension for Rust Currently in development, and not feature complete. Stable versions are available on the Visual Studio extension gall

PistonDevelopers 697 Dec 18, 2022
Rust extension for Visual Studio 2017 with RLS support

Rust support for Visual Studio 2017 Preview Adds language support for Rust to Visual Studio 2017. Supports: code completion goto definition find all r

Zoey Riordan 111 Aug 4, 2022
crates is an extension aims to help people to manage their dependencies for rust (crates.io & TOML).

crates Hello Rust & VSCode lovers, This is crates, an extension for crates.io dependencies. Aims helping developers to manage dependencies while using

Seray Uzgur 164 Jan 4, 2023
Rust On the FLY completion for neovim

rofl.nvim Rust On the FLy completion engine for Neovim. Why Rust? It's 2021. I think the question you should be asking yourself is "Why NOT Rust?!?? (

TJ DeVries 63 Sep 25, 2022
A *seriously* no-bullshit Neovim GUI written in Rust and Tauri

Looking for a shareable component template? Go here --> sveltejs/component-template svelte app This is a project template for Svelte apps. It lives at

null 13 Nov 21, 2022