diff options
Diffstat (limited to 'crates/ide/src')
-rw-r--r-- | crates/ide/src/diagnostics.rs | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/crates/ide/src/diagnostics.rs b/crates/ide/src/diagnostics.rs index c92c1c066..394365bc8 100644 --- a/crates/ide/src/diagnostics.rs +++ b/crates/ide/src/diagnostics.rs | |||
@@ -10,7 +10,10 @@ mod field_shorthand; | |||
10 | use std::cell::RefCell; | 10 | use std::cell::RefCell; |
11 | 11 | ||
12 | use base_db::SourceDatabase; | 12 | use base_db::SourceDatabase; |
13 | use hir::{diagnostics::DiagnosticSinkBuilder, Semantics}; | 13 | use hir::{ |
14 | diagnostics::{Diagnostic as _, DiagnosticSinkBuilder}, | ||
15 | Semantics, | ||
16 | }; | ||
14 | use ide_db::RootDatabase; | 17 | use ide_db::RootDatabase; |
15 | use itertools::Itertools; | 18 | use itertools::Itertools; |
16 | use rustc_hash::FxHashSet; | 19 | use rustc_hash::FxHashSet; |
@@ -46,6 +49,10 @@ impl Diagnostic { | |||
46 | fn with_fix(self, fix: Option<Fix>) -> Self { | 49 | fn with_fix(self, fix: Option<Fix>) -> Self { |
47 | Self { fix, ..self } | 50 | Self { fix, ..self } |
48 | } | 51 | } |
52 | |||
53 | fn with_unused(self, unused: bool) -> Self { | ||
54 | Self { unused, ..self } | ||
55 | } | ||
49 | } | 56 | } |
50 | 57 | ||
51 | #[derive(Debug)] | 58 | #[derive(Debug)] |
@@ -115,6 +122,13 @@ pub(crate) fn diagnostics( | |||
115 | .on::<hir::diagnostics::IncorrectCase, _>(|d| { | 122 | .on::<hir::diagnostics::IncorrectCase, _>(|d| { |
116 | res.borrow_mut().push(warning_with_fix(d, &sema)); | 123 | res.borrow_mut().push(warning_with_fix(d, &sema)); |
117 | }) | 124 | }) |
125 | .on::<hir::diagnostics::UnconfiguredCode, _>(|d| { | ||
126 | // Override severity and mark as unused. | ||
127 | res.borrow_mut().push( | ||
128 | Diagnostic::hint(sema.diagnostics_display_range(d).range, d.message()) | ||
129 | .with_unused(true), | ||
130 | ); | ||
131 | }) | ||
118 | // Only collect experimental diagnostics when they're enabled. | 132 | // Only collect experimental diagnostics when they're enabled. |
119 | .filter(|diag| !(diag.is_experimental() && config.disable_experimental)) | 133 | .filter(|diag| !(diag.is_experimental() && config.disable_experimental)) |
120 | .filter(|diag| !config.disabled.contains(diag.code().as_str())); | 134 | .filter(|diag| !config.disabled.contains(diag.code().as_str())); |