Choose VS Code with rust-analyzer for most Rust work on Windows, macOS, or Linux. Install Rust through rustup, add the rust-analyzer extension from the VS Code marketplace, and use Cargo from the integrated terminal. If you already use Visual Studio 2022 heavily and want its debugger and Error List integration, install SourceGear Rust; for Test Explorer add rust-analyzer.vs, which requires the nightly Rust toolchain for test features.
Visual Studio, VS Code, and Build Tools are different products
Visual Studio Code is a lightweight, cross-platform editor with Rust support provided by the rust-analyzer extension. Visual Studio 2022 is a full Windows IDE; third-party extensions such as SourceGear Rust and rust-analyzer.vs integrate Cargo builds and debugging, with rust-analyzer.vs adding Test Explorer support when the nightly toolchain is installed. Microsoft C++ Build Tools is a standalone package that supplies the linker and libraries required by Rust's default Windows toolchain without installing the Visual Studio IDE.
All three serve different purposes. VS Code gives you a documented, rust-analyzer-based editing and debugging environment. Visual Studio gives you an IDE with Windows-focused features such as Error List integration and, through rust-analyzer.vs, Test Explorer. Build Tools provides only the compiler toolchain—no editor at all.
The most common confusion is that "Visual Studio" can refer to the full IDE or to VS Code. They are separate applications with different Rust workflows.
Rust toolchains on Windows: rustup and MSVC
Rust on Windows defaults to the *-windows-msvc toolchain, which requires Microsoft's C++ linker and Windows libraries. You supply these by installing Visual Studio or the standalone Microsoft C++ Build Tools and selecting the Desktop development with C++ workload. Without this step, cargo build fails with link.exe not found.
After the Build Tools or Visual Studio installation completes, download and run the rustup installer. Accept the default MSVC toolchain. Verify the installation by opening a new terminal and running cargo --version and rustc --version.
Restart terminals and editors after installing Rust so the updated PATH is recognized. Rust tools live in %USERPROFILE%\.cargo\bin on Windows or ~/.cargo/bin on Linux and macOS. The rustup installer normally adds this directory to your PATH, but shells already open will not see the change until restarted.
To keep Rust up to date, run rustup update every few weeks. Stable Rust releases ship every six weeks.
Set up Rust in VS Code with rust-analyzer
Install VS Code from the official site. Open the Extensions view with Ctrl+Shift+X, search for "rust-analyzer," and install the Release Version. The older rust-lang.rust extension is deprecated and should not be used.
Create a new Rust project and open it in VS Code:
- Open a terminal and run:
cargo new hello_world cd hello_world code . - The rust-analyzer extension detects
Cargo.tomland begins indexing the project. Watch the status bar in the lower left until indexing completes. - Open the integrated terminal in VS Code (Ctrl+` ) and build or run the project:
cargo build cargo run
VS Code provides completion, hover documentation, go-to-definition, find-references, inlay type hints, and refactorings through rust-analyzer. The linter runs rustc diagnostics by default. To get additional lints from Clippy, change the rust-analyzer.check.command setting to clippy. Formatting uses rustfmt and can be triggered manually or enabled on save with the editor.formatOnSave setting.
Debugging requires one additional extension. On Windows, install the Microsoft C++ extension (ms-vscode.cpptools). On macOS and Linux, install CodeLLDB (vadimcn.vscode-lldb). After installing the debugger extension, rust-analyzer adds Debug and Run CodeLens actions above main() and test functions. Set breakpoints by clicking the left gutter in the editor, then click the Debug action or press F5.
What Rust support exists in Visual Studio IDE
Visual Studio 2022 on Windows supports Rust through third-party extensions available in the Visual Studio Marketplace. The two main extensions are SourceGear Rust and rust-analyzer.vs. Both use Visual Studio's Open Folder mode instead of solution and project files, so you open the folder containing Cargo.toml rather than creating a .sln.
To set up Rust in Visual Studio:
- Install Visual Studio 2022 Community, Professional, or Enterprise.
- In the Visual Studio Installer, select Desktop development with C++.
- Install Rust with rustup.
- Install a Rust extension from the Visual Studio Marketplace—either SourceGear Rust or rust-analyzer.vs.
- Restart Visual Studio, then use File > Open > Folder to open your Cargo project folder.
SourceGear Rust supports Visual Studio 2022 Community, Professional, and Enterprise. It provides rust-analyzer IntelliSense, Cargo build and clean commands, debugging, syntax coloring for .rs and .toml, Error List integration, a dependency management UI, and Cargo workspace support. The extension includes a Rust View that shows the package, target, and dependency hierarchy instead of the file-system folder view.
rust-analyzer.vs supports Visual Studio 2022 17.12+ and Visual Studio 2026 18.x on Windows amd64. It provides rust-analyzer-based IntelliSense, Cargo build and clean, run and debug support, unit-test management through Test Explorer, and Clippy and formatting integration. The extension documentation states that Test Explorer currently requires the nightly Rust toolchain and that bugs exist. Cross-compilation, WSL2 support, and templates are listed as upcoming or probably-never work.
rust-analyzer.vs is an independent project not endorsed by Microsoft or the rust-analyzer project. SourceGear Rust is a third-party Visual Studio extension. Both are useful and free, but they are not first-party language integrations. Check the extension's documentation for current feature coverage and prerequisites before committing to a Visual Studio-based Rust workflow.
Cargo, tests, debugging, and daily development
In VS Code, you run Cargo commands from the integrated terminal. Type cargo build, cargo test, cargo run, or cargo clippy as needed. rust-analyzer provides inline diagnostics and quick fixes as you type, and the linter updates when you save a file.
In Visual Studio, SourceGear Rust and rust-analyzer.vs add build and clean commands to the IDE menus and integrate Rust compiler errors into the Error List. Double-clicking an error opens the source file at the error location. Debugging launches from the toolbar or F5 after you set the startup target. rust-analyzer.vs can manage unit tests through Visual Studio's Test Explorer, but this feature requires the nightly toolchain.
Both environments use the same underlying tools—rustup, Cargo, rust-analyzer, rustc, clippy, and rustfmt. The difference is whether you interact with them through terminal commands or through IDE menus and windows. VS Code keeps the terminal workflow front and center. Visual Studio wraps the workflow in IDE features such as Error List and, for rust-analyzer.vs, Test Explorer and integrated debugging.
In VS Code, enable editor.formatOnSave to run rustfmt automatically. In Visual Studio, rust-analyzer.vs documents Clippy and formatting integration; check the extension's documentation for current behavior.
Which Rust editor should you choose?
Choose VS Code + rust-analyzer if you are new to Rust, work on multiple platforms, need remote development, or want a widely documented Rust setup. The rust-analyzer extension has IntelliSense, refactoring, and debugging support, and the VS Code documentation walks through the entire installation and usage workflow.
Choose Visual Studio 2022 + a Rust extension if you already use Visual Studio for other languages, want Error List integration, and develop primarily for Windows. For Test Explorer, install rust-analyzer.vs and the nightly toolchain; for general Cargo and debugging integration, SourceGear Rust also works. Both extensions are third-party projects with documented limitations and ongoing development, so verify that the extension you choose supports the Visual Studio version and Rust features your project requires.
If you only need the Windows linker and do not use Visual Studio for other work, install the standalone Microsoft C++ Build Tools and use VS Code. The Build Tools package does not install the Visual Studio IDE and provides only the toolchain Rust needs to link Windows binaries.
Quick verification checklist after setup
After installing Rust and your chosen editor, confirm the setup with these checks:
- Open a new terminal and run
cargo --versionandrustc --version. Both should print version numbers. - Create a test project with
cargo new test_project, navigate into it, and runcargo build. The build should succeed without linker errors. - Open the project folder in your editor. In VS Code, rust-analyzer's status bar indicator should complete indexing. In Visual Studio, Rust View or Folder View should recognize
Cargo.tomland show project structure. - Open
src/main.rsand confirm that code completion and hover documentation work. - Set a breakpoint on the
println!line, press F5 or use the Debug action, and verify that the debugger stops at the breakpoint. In VS Code, this requires the Microsoft C++ or CodeLLDB extension. In Visual Studio, the Rust extension handles debugging.
For a real Rust desktop application to open in either editor, see ArtCraft Launcher, which installs and updates the Rust-built Craft apps.
Frequently asked questions
Can Rust be used in Visual Studio?
Yes. Visual Studio 2022 on Windows supports Rust through third-party extensions such as SourceGear Rust and rust-analyzer.vs. These extensions provide rust-analyzer IntelliSense, Cargo build integration, debugging, and Error List support through Visual Studio's Open Folder mode.
How do I set up Rust in Visual Studio on Windows?
Install Visual Studio 2022 with the Desktop development with C++ workload. Install Rust using rustup. Install a Visual Studio Rust extension from the Marketplace, then use File > Open > Folder to open your Cargo project folder. If you only need the linker and plan to use VS Code, install the standalone Microsoft C++ Build Tools instead of the full Visual Studio IDE.
Should I use Visual Studio or VS Code for Rust?
Use VS Code for most Rust development. It has widely documented setup, rust-analyzer integration, and support for Windows, macOS, Linux, and remote development. Use Visual Studio 2022 if you already work in that IDE and want its Error List and, through rust-analyzer.vs, Test Explorer. Visual Studio Rust support is provided by third-party extensions and is Windows-focused.
Next step
If you chose VS Code, install the rust-analyzer extension and create your first project with cargo new. If you chose Visual Studio, install SourceGear Rust or rust-analyzer.vs from the Visual Studio Marketplace and open a Cargo folder. On Windows, both paths require the Desktop development with C++ workload or standalone Build Tools to supply the linker.
Verification status: Supported by official documentation only under the conditions below; not reproduced in a test environment by IGPROD. Checked 2026-10-14.
Applies to: Visual Studio 2022 for Windows.
Conditions:
- VS Code setup assumes Rust is installed via rustup and platform extra tools are installed as needed.
- VS Code rust-analyzer should be installed as the Release Version.
- VS Code debugging requires Microsoft C++ on Windows or CodeLLDB on macOS/Linux.
- SourceGear Rust supports Visual Studio 2022 for Windows Community, Professional, or Enterprise.
- SourceGear Rust does not support Visual Studio for Mac or Visual Studio Code.
- SourceGear Rust needs Rust tools installed and available in PATH.
- SourceGear Rust uses Visual Studio Open Folder mode instead of project files and solutions.
- rust-analyzer.vs supports Windows amd64 VSIX for VS 2022 17.12+ and VS 2026 18.x.
- rust-analyzer.vs requires Core Editor, rustup on the Visual Studio process PATH, a default toolchain, and Cargo.
- For rust-analyzer.vs, nightly is optional and needed only for Test Explorer.
Related guides
- Run Rust on an Arduino Uno from Linux: a hands-on Rust project once your editor is set up.
Sources:
- vscode-docs/docs/languages/rust.md at main · microsoft/vscode-docs · GitHub (github.com)
- rust-vs-extension/getting_started.md at main · sourcegear/rust-vs-extension · GitHub (github.com)
- GitHub - kitamstudios/rust-analyzer.vs: Rust language support for Visual Studio 2022 · GitHub (gith…
- github.com/PistonDevelopers/VisualRust
Leave a comment
Your email address will not be published. Required fields are marked *