Configuring Visual Studio Code for Rust

  1. When I compile a program in VSC using F5 and get errors, the compiler output stays in the Terminal window and lets me investigate the details. When the program compiles without errors but possibly with warnings, the compiler output disappears as soon as the program starts executing. In this case, how do you keep the compiler output?

  2. Problems in the source code found during compilation are marked by underlining the suspicious code with a red line, sometimes many code lines. This makes the code difficult to read because you basically lose small characters like a dot or comma. Is there any way to get rid of this underlining?

  3. There is an extension that adds inlays to the source code showing the types of the variables, return values, etc. Which extension is it, and how do you switch the inlays on and off?

This a little late answer, but anyhow.

I don't have an answer for the first two points but the last one I do. The inlay is a feature of the rust-analyzer extension. You can turn it off by specifying the following in your settings:

"[rust]": {
        "editor.inlayHints.enabled": "off",
    },

But I recommend using "offUnlessPressed" instead of "off" which will display the inlay hints when "Ctrl + Alt" are pressed.

plus tangentially related, please excuse pseudo-necro-posting...

late versions of vscode (change happened several months back - or was it more already?)
seem to have made inlays IMHO very ugly and hard to distinguish from real code lines/text.
I resolved it by keeping imho very (VERY) useful inlays on, but customized colors to be less intrusive via global settings.json (some people/topics here on discuss provided this tip for me).

// +- own preferred colorization/alpha setting...
"workbench.colorCustomizations": {
  "editorInlayHint.foreground": "#d4d4d455",
  "editorInlayHint.background": "#00000000",
  "editorInlayHint.parameterBackground": "#00000000",
  "editorInlayHint.typeBackground": "#00000000"
},

(edit: above combination works for me using dark mode/theme, just edit foreground color setting to whatever fits your case)

I inserted these lines into launch.json after "version": "0.2.0" and before "configurations": [...] but I didn't see any difference in the VSCode. I've tried some other placements in the file, but all generated errors.

The problem that I reported in the topic is now mitigated because I've switched off many of the rust-analyzer's Inlay Hints. Concerning the disturbing red underlining of suspicious code, I've noticed that when you compile the same code a second time, the underlining disappears. On the whole, I'm now rather satisfied with the VSCode.

I am rather naive vscode user, dont have much in-depth experience with fine-tuning.
The lines i pasted i had inside of root of the object in glogal settings.json.
I dont have experience with other setup files.

I always opened it for modifications via keyboard shortcut in vscode - "ctrl + shift + p" (run command?) and typing "Preferences: Open user settings (JSON)"... (part of if, until i filter/see it and run)

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.