From 5c6ab1145319414e897a8eaca2bf1ad5558ccf24 Mon Sep 17 00:00:00 2001 From: Ryan Cumming Date: Tue, 25 Jun 2019 21:44:27 +1000 Subject: Tweak isUnusedOrUnnecessary The first cut was a bit rough with the blanket `unused_*` rule. This trigger for things like `unused_mut` where the code is used but it's suboptimal. It's misleading to grey out the code in those cases. Instead, use an explicit list of things known to be dead code. --- editors/code/src/utils/rust_diagnostics.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'editors/code/src') diff --git a/editors/code/src/utils/rust_diagnostics.ts b/editors/code/src/utils/rust_diagnostics.ts index 7d8cc0e0b..ed049c95e 100644 --- a/editors/code/src/utils/rust_diagnostics.ts +++ b/editors/code/src/utils/rust_diagnostics.ts @@ -95,8 +95,14 @@ function isUnusedOrUnnecessary(rd: RustDiagnostic): boolean { return false; } - const { code } = rd.code; - return code.startsWith('unused_') || code === 'dead_code'; + return [ + 'dead_code', + 'unknown_lints', + 'unused_attributes', + 'unused_imports', + 'unused_macros', + 'unused_variables' + ].includes(rd.code.code); } /** -- cgit v1.2.3