diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2020-06-03 07:16:45 +0100 |
---|---|---|
committer | GitHub <[email protected]> | 2020-06-03 07:16:45 +0100 |
commit | 6d38351db420bd7d069d17783f83b8936ffe361b (patch) | |
tree | 617ec9754a237837f358a0420ec42084173a146c | |
parent | dff8140a2e9de8b6d9c64cfcc9a8d16db3a0fecd (diff) | |
parent | 599c105e6fabb2b81c2d0a11b86c0c96f6ab1b88 (diff) |
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 <[email protected]>
-rw-r--r-- | crates/rust-analyzer/src/diagnostics/snapshots/rust_analyzer__diagnostics__to_proto__tests__snap_rustc_unused_variable.snap | 2 | ||||
-rw-r--r-- | crates/rust-analyzer/src/diagnostics/to_proto.rs | 3 |
2 files changed, 3 insertions, 2 deletions
diff --git a/crates/rust-analyzer/src/diagnostics/snapshots/rust_analyzer__diagnostics__to_proto__tests__snap_rustc_unused_variable.snap b/crates/rust-analyzer/src/diagnostics/snapshots/rust_analyzer__diagnostics__to_proto__tests__snap_rustc_unused_variable.snap index 6dd3fcb2e..33b516e26 100644 --- a/crates/rust-analyzer/src/diagnostics/snapshots/rust_analyzer__diagnostics__to_proto__tests__snap_rustc_unused_variable.snap +++ b/crates/rust-analyzer/src/diagnostics/snapshots/rust_analyzer__diagnostics__to_proto__tests__snap_rustc_unused_variable.snap | |||
@@ -29,7 +29,7 @@ expression: diag | |||
29 | }, | 29 | }, |
30 | }, | 30 | }, |
31 | severity: Some( | 31 | severity: Some( |
32 | Warning, | 32 | Hint, |
33 | ), | 33 | ), |
34 | code: Some( | 34 | code: Some( |
35 | String( | 35 | String( |
diff --git a/crates/rust-analyzer/src/diagnostics/to_proto.rs b/crates/rust-analyzer/src/diagnostics/to_proto.rs index a500d670a..6a6e7b457 100644 --- a/crates/rust-analyzer/src/diagnostics/to_proto.rs +++ b/crates/rust-analyzer/src/diagnostics/to_proto.rs | |||
@@ -183,7 +183,7 @@ pub(crate) fn map_rust_diagnostic_to_lsp( | |||
183 | return Vec::new(); | 183 | return Vec::new(); |
184 | } | 184 | } |
185 | 185 | ||
186 | let severity = map_level_to_severity(rd.level); | 186 | let mut severity = map_level_to_severity(rd.level); |
187 | 187 | ||
188 | let mut source = String::from("rustc"); | 188 | let mut source = String::from("rustc"); |
189 | let mut code = rd.code.as_ref().map(|c| c.code.clone()); | 189 | let mut code = rd.code.as_ref().map(|c| c.code.clone()); |
@@ -225,6 +225,7 @@ pub(crate) fn map_rust_diagnostic_to_lsp( | |||
225 | } | 225 | } |
226 | 226 | ||
227 | if is_unused_or_unnecessary(rd) { | 227 | if is_unused_or_unnecessary(rd) { |
228 | severity = Some(DiagnosticSeverity::Hint); | ||
228 | tags.push(DiagnosticTag::Unnecessary); | 229 | tags.push(DiagnosticTag::Unnecessary); |
229 | } | 230 | } |
230 | 231 | ||