diff options
author | Jonas Schievink <[email protected]> | 2020-10-20 16:49:21 +0100 |
---|---|---|
committer | Jonas Schievink <[email protected]> | 2020-10-20 16:53:04 +0100 |
commit | 80d27414016903fa591548cff22939d3c43cdd8d (patch) | |
tree | 7e1af2330d87fcefcfcea4e8babfe4130c1e3786 /crates/ide | |
parent | a54e481646edb151075d12ca6903091abe7cfc4e (diff) |
Add a (hint) diagnostic for unconfigured items
Diffstat (limited to 'crates/ide')
-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())); |