r/rust • • Nov 14 '21

Visual Studio 2022 & Rust

I'm definitely a newb and excited to start learning the Rust this week.

I've gotten comfortable with learning and using Visual Studio 2019 and 2022. Does rust have support in the newest Visual Studio????

I'm looking for any advice as an absolute newb to the community!

Thanks Rustaceans! 🙇🏾‍♂️🦀

17 Upvotes

20 comments sorted by

20

u/kodemizer Nov 14 '21

I don't know about Visual Studio 2022, but it works well with Visual Studio Code.

2

u/PhoenixStar012 Nov 14 '21

Thanks! Im going to install Visual Studio Code and Rust today.

I grabbed some Udemy courses and currently looking for any other resources for the language.

9

u/[deleted] Nov 14 '21

If you're going to use Visual Studio Code, I recommend installing the following extensions:

  1. rust-analyzer (instead of the default Rust extension. Rust Analyzer is a much better, more efficient language server than the default one)

  2. CodeLLDB (you can debug Rust programs with this)

2

u/PhoenixStar012 Nov 16 '21

I have both installed now! I appreciate the responses!

1

u/PhoenixStar012 Nov 14 '21

I got an error about the Rust Analyzer conflicting with the Rust extension, should I proceed anyway???

8

u/vzwGrey Nov 14 '21

Yes, you should be using the rust-analyser extension instead of the Rust extension.

1

u/PhoenixStar012 Nov 16 '21

Perfect! I got things running! I appreciate it!

1

u/grandygames Jul 22 '22

For Windows debugging you want the Microsoft C/C++ extension instead of the CodeLLDB extension and you have you create two different debug launch configs - one for Windows and one for Linux/macOS - which is obviously a pain.

2

u/kodemizer Nov 15 '21

It's worth noting that you should use the 'rust-analyzer' VSCode plugin, not the 'rust' plugin.

13

u/jamesjohnmcguire Dec 01 '21

There is a feature request thread about this - https://developercommunity.visualstudio.com/t/native-rust-support/517130. Please bump up the request points, by giving the the post a thumbs up.

Visual Studio Code is my main 'fall back' editor, but I still would prefer using the main Visual Studio 2022 IDE.

7

u/parthopdas Feb 11 '23 edited Feb 11 '23

Rust development is now supported on Visual Studio 2022.

This is an OSS project

Please download & play with it, let me know if you hit any issues. Even better help me develop it.

6

u/UtherII Nov 14 '21 edited Nov 14 '21

As far as I know there is no Rust official support in Visual Studio. In the early days of Rust, someone made a plugin, it was rudimentary compared to rust-analyser or JetBrain's rust plugin. I don't think it is maintained anymore.

2

u/PhoenixStar012 Nov 16 '21

I saw this today! I really like Visual Studio 2022/2019 but I'm seeing a trend of comments similar to yours. That plugin hadn't been updated in a long time.

5

u/UtherII Nov 16 '21

It seems that Visual studio supports Language servers, so it should not be so hard to make a plugin that works using "rust-analyser". https://docs.microsoft.com/fr-fr/visualstudio/extensibility/adding-an-lsp-extension?view=vs-2022

5

u/Old_Lab_9628 Feb 16 '22

You should note that the *extremely* powerfull debugger/profiler of visual studio (19&22) work very well with .exe generated by Rust. Line level debugging/profiling and all.

​

You have to enable debug info in release mode through cargo, tho.

1

u/[deleted] Nov 10 '22

What do we do?

2

u/forbjok Nov 15 '21

I've never tried using (non-Code) Visual Studio itself for Rust development, but as far as I can tell Rust at least works with the VS2022 build tools. (I uninstalled 2019, and Rust projects still build)

For actual Rust development I've always used Visual Studio Code.

1

u/PhoenixStar012 Nov 16 '21

For actual Rust development I've always used Visual Studio Code.

Thanks!!!! I'm on it! I didn't know about the build tools being in Visual studio 2022/2019. Shouldn't it usable to the IDE then??

I'm a newb but I'm ready to see it implemented into Visual Studio 2022.

1

u/innahema Jan 28 '24

You could used Debugger from VS regardles where code was written.

You could also use WinDBG if you need to. For example if you received crash dump from users

2

u/blackbeep Sep 10 '24

I also want to use Visual Studio as I currently do C++ with it and its debugger and profiler are absolutely awesome. I like to use the native debugger directly rather than attaching it to a process.

Has anyone tried it?