diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2019-06-27 09:01:23 +0100 |
---|---|---|
committer | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2019-06-27 09:01:23 +0100 |
commit | e8dc92ca734e34b25291015008d5c6dfd933fa7a (patch) | |
tree | 399527ebfd1c7c36027aef8f03c337e6c160512a /editors/code/src/utils | |
parent | b13a217a8b975d037b50c1b0e15073eabba582f8 (diff) | |
parent | a8a1bc4b15b75e5702cb1ce1d4c5ab3153dbe3c9 (diff) |
Merge #1450
1450: Extract lint scopes from `cargo watch` r=matklad a=etaoins
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](https://github.com/rust-lang/rfcs/blob/master/text/2103-tool-attributes.md)) 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`.
Co-authored-by: Ryan Cumming <[email protected]>
Diffstat (limited to 'editors/code/src/utils')
-rw-r--r-- | editors/code/src/utils/rust_diagnostics.ts | 14 |
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) { |