aboutsummaryrefslogtreecommitdiff
path: root/editors/code/src/utils/rust_diagnostics.ts
diff options
context:
space:
mode:
authorRyan Cumming <[email protected]>2019-06-26 23:47:36 +0100
committerRyan Cumming <[email protected]>2019-06-26 23:52:22 +0100
commita8a1bc4b15b75e5702cb1ce1d4c5ab3153dbe3c9 (patch)
treed4ecd189aa2dcdccb477e0edcac9b72cb11032a3 /editors/code/src/utils/rust_diagnostics.ts
parent04a211ff6146d167a2bdf7d200df36468137591b (diff)
Extract lint scopes from `cargo watch`
Currently all of our VS Code diagnostics are given the source of `rustc`. However, if you have something like `cargo-watch.command` set to `clippy` it will also watch for Clippy lints. The `rustc` source is a bit misleading in that case. Fortunately, Rust's tool lints (RFC 2103) line up perfectly with VS Code's concept of `source`. This checks for lints scoped to a given tool and then splits them in to a `source` and tool-specific `code`.
Diffstat (limited to 'editors/code/src/utils/rust_diagnostics.ts')
-rw-r--r--editors/code/src/utils/rust_diagnostics.ts14
1 files changed, 12 insertions, 2 deletions
diff --git a/editors/code/src/utils/rust_diagnostics.ts b/editors/code/src/utils/rust_diagnostics.ts
index ed049c95e..3c524cb37 100644
--- a/editors/code/src/utils/rust_diagnostics.ts
+++ b/editors/code/src/utils/rust_diagnostics.ts
@@ -187,8 +187,18 @@ export function mapRustDiagnosticToVsCode(
187 187
188 const vd = new vscode.Diagnostic(location.range, rd.message, severity); 188 const vd = new vscode.Diagnostic(location.range, rd.message, severity);
189 189
190 vd.source = 'rustc'; 190 let source = 'rustc';
191 vd.code = rd.code ? rd.code.code : undefined; 191 let code = rd.code && rd.code.code;
192 if (code) {
193 // See if this is an RFC #2103 scoped lint (e.g. from Clippy)
194 const scopedCode = code.split('::');
195 if (scopedCode.length === 2) {
196 [source, code] = scopedCode;
197 }
198 }
199
200 vd.source = source;
201 vd.code = code;
192 vd.relatedInformation = []; 202 vd.relatedInformation = [];
193 203
194 for (const secondarySpan of secondarySpans) { 204 for (const secondarySpan of secondarySpans) {