diff --git a/editors/code/src/test/utils/diagnotics/rust.test.ts b/editors/code/src/test/utils/diagnotics/rust.test.ts index 7fb003fe212..327d15046f5 100644 --- a/editors/code/src/test/utils/diagnotics/rust.test.ts +++ b/editors/code/src/test/utils/diagnotics/rust.test.ts @@ -50,7 +50,7 @@ describe('mapRustDiagnosticToVsCode', () => { ].join('\n') ); assert.strictEqual(diagnostic.code, 'E0053'); - assert.strictEqual(diagnostic.tags, undefined); + assert.deepStrictEqual(diagnostic.tags, []); // No related information assert.deepStrictEqual(diagnostic.relatedInformation, []); @@ -115,7 +115,7 @@ describe('mapRustDiagnosticToVsCode', () => { ); assert.strictEqual(diagnostic.code, 'E0061'); assert.strictEqual(diagnostic.source, 'rustc'); - assert.strictEqual(diagnostic.tags, undefined); + assert.deepStrictEqual(diagnostic.tags, []); // One related information for the original definition const relatedInformation = diagnostic.relatedInformation; @@ -149,7 +149,7 @@ describe('mapRustDiagnosticToVsCode', () => { ].join('\n') ); assert.strictEqual(diagnostic.code, 'trivially_copy_pass_by_ref'); - assert.strictEqual(diagnostic.tags, undefined); + assert.deepStrictEqual(diagnostic.tags, []); // One related information for the lint definition const relatedInformation = diagnostic.relatedInformation; @@ -189,7 +189,7 @@ describe('mapRustDiagnosticToVsCode', () => { ); assert.strictEqual(diagnostic.code, 'E0308'); assert.strictEqual(diagnostic.source, 'rustc'); - assert.strictEqual(diagnostic.tags, undefined); + assert.deepStrictEqual(diagnostic.tags, []); // No related information assert.deepStrictEqual(diagnostic.relatedInformation, []); diff --git a/editors/code/src/utils/diagnostics/rust.ts b/editors/code/src/utils/diagnostics/rust.ts index 1fb1f7b6dc8..0550d037247 100644 --- a/editors/code/src/utils/diagnostics/rust.ts +++ b/editors/code/src/utils/diagnostics/rust.ts @@ -111,6 +111,17 @@ function isUnusedOrUnnecessary(rd: RustDiagnostic): boolean { ].includes(rd.code.code); } +/** + * Determines if diagnostic is related to deprecated code + */ +function isDeprecated(rd: RustDiagnostic): boolean { + if (!rd.code) { + return false; + } + + return ['deprecated'].includes(rd.code.code); +} + /** * Converts a Rust child diagnostic to a VsCode related information * @@ -200,6 +211,7 @@ export function mapRustDiagnosticToVsCode( vd.source = source; vd.code = code; vd.relatedInformation = []; + vd.tags = []; for (const secondarySpan of secondarySpans) { const related = mapSecondarySpanToRelated(secondarySpan); @@ -234,7 +246,11 @@ export function mapRustDiagnosticToVsCode( } if (isUnusedOrUnnecessary(rd)) { - vd.tags = [vscode.DiagnosticTag.Unnecessary]; + vd.tags.push(vscode.DiagnosticTag.Unnecessary); + } + + if (isDeprecated(rd)) { + vd.tags.push(vscode.DiagnosticTag.Deprecated); } return {