Skip to content

Commit 6d38351

Browse files
bors[bot]GabbeV
andauthored
Merge #4721
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>
2 parents dff8140 + 599c105 commit 6d38351

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

crates/rust-analyzer/src/diagnostics/snapshots/rust_analyzer__diagnostics__to_proto__tests__snap_rustc_unused_variable.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ expression: diag
2929
},
3030
},
3131
severity: Some(
32-
Warning,
32+
Hint,
3333
),
3434
code: Some(
3535
String(

crates/rust-analyzer/src/diagnostics/to_proto.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ pub(crate) fn map_rust_diagnostic_to_lsp(
183183
return Vec::new();
184184
}
185185

186-
let severity = map_level_to_severity(rd.level);
186+
let mut severity = map_level_to_severity(rd.level);
187187

188188
let mut source = String::from("rustc");
189189
let mut code = rd.code.as_ref().map(|c| c.code.clone());
@@ -225,6 +225,7 @@ pub(crate) fn map_rust_diagnostic_to_lsp(
225225
}
226226

227227
if is_unused_or_unnecessary(rd) {
228+
severity = Some(DiagnosticSeverity::Hint);
228229
tags.push(DiagnosticTag::Unnecessary);
229230
}
230231

0 commit comments

Comments
 (0)