1

I am coding in Rust by using VS Code, but the variable that i'm not used shows a ugly wavy underline, i want to disable it and just make my unused variables being gray which seems like IntelliJ IDEA shows unused functions.

VS Code:

VS Code

goland

goland

starball
  • 20,030
  • 7
  • 43
  • 238
Stop
  • 13
  • 2

2 Answers2

2

As shown in Chayim's answer you can change change the warnings to hints, which have a more subtle visual cue. I'm not sure of a way to remove all underline-related visual cues. Like so:

"rust-analyzer.diagnostics.warningsAsHint": [
   "unused_variables"
],

As for highlighting it grey, the Rust Analyzer extension doesn't provide any dedicated semantic token for unused things at the time of this writing (I checked using the Developer: Inspect Editor Tokens and Scopes command). Semantic highlighting has a mechanism for "modifiers". There isn't yet a modifier for unused things, but there's a feature-request for that here: SemanticTokensModifier: Add unused token modifier #604. You can give that issue ticket a thumbs up to show support for it, and subscribe to it to get notified about discussion and progress. If/when it does get implemented, you'd then also have to wait for the Rust Analyzer extension to make use of the feature.

starball
  • 20,030
  • 7
  • 43
  • 238
0

I don't believe you can make the name grey, but you can avoid the squiggles by changing the settings. In settings.json of VS Code:

{
    "rust-analyzer.diagnostics.warningsAsHint": [
        "dead_code",
        "unused_variables"
    ]
}
Chayim Friedman
  • 47,971
  • 5
  • 48
  • 77