]> git.lizzy.rs Git - rust.git/commitdiff
Tweak isUnusedOrUnnecessary
authorRyan Cumming <etaoins@gmail.com>
Tue, 25 Jun 2019 11:44:27 +0000 (21:44 +1000)
committerRyan Cumming <etaoins@gmail.com>
Tue, 25 Jun 2019 11:44:27 +0000 (21:44 +1000)
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

index 7d8cc0e0b8dab68d9e6628230eb30b85481aab7d..ed049c95ef0db60f594565c1216daee4b115e9a8 100644 (file)
@@ -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);
 }
 
 /**