4721: Hide squiggly for unused and unnecessary diagnostics r=matklad a=GabbeV

Fixes #4229 

When working with JavaScript or TypeScript in VSCode unused valiables are faded but don't have a squiggle. This PR makes rust-analyzer work similarly by setting the severity to hint when applying the unnecessary tag.

VSCode usually shows a squiggle for error, warning and information and shows three dots for hint. When the unnecessary tag is present the squiggles will still show up but the three dots will not.

This is my first contribution to open source. Please tell me if i need to do anything more to get this PR considered.

Co-authored-by: Gabriel Valfridsson <gabriel.valfridsson@gmail.com>
This commit is contained in:
bors[bot] 2020-06-03 06:16:45 +00:00 committed by GitHub
commit 6d38351db4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 2 deletions

View file

@ -29,7 +29,7 @@ expression: diag
},
},
severity: Some(
Warning,
Hint,
),
code: Some(
String(

View file

@ -183,7 +183,7 @@ pub(crate) fn map_rust_diagnostic_to_lsp(
return Vec::new();
}
let severity = map_level_to_severity(rd.level);
let mut severity = map_level_to_severity(rd.level);
let mut source = String::from("rustc");
let mut code = rd.code.as_ref().map(|c| c.code.clone());
@ -225,6 +225,7 @@ pub(crate) fn map_rust_diagnostic_to_lsp(
}
if is_unused_or_unnecessary(rd) {
severity = Some(DiagnosticSeverity::Hint);
tags.push(DiagnosticTag::Unnecessary);
}