From 80d27414016903fa591548cff22939d3c43cdd8d Mon Sep 17 00:00:00 2001 From: Jonas Schievink Date: Tue, 20 Oct 2020 17:49:21 +0200 Subject: Add a (hint) diagnostic for unconfigured items --- crates/ide/src/diagnostics.rs | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'crates/ide/src') 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; use std::cell::RefCell; use base_db::SourceDatabase; -use hir::{diagnostics::DiagnosticSinkBuilder, Semantics}; +use hir::{ + diagnostics::{Diagnostic as _, DiagnosticSinkBuilder}, + Semantics, +}; use ide_db::RootDatabase; use itertools::Itertools; use rustc_hash::FxHashSet; @@ -46,6 +49,10 @@ impl Diagnostic { fn with_fix(self, fix: Option) -> Self { Self { fix, ..self } } + + fn with_unused(self, unused: bool) -> Self { + Self { unused, ..self } + } } #[derive(Debug)] @@ -115,6 +122,13 @@ pub(crate) fn diagnostics( .on::(|d| { res.borrow_mut().push(warning_with_fix(d, &sema)); }) + .on::(|d| { + // Override severity and mark as unused. + res.borrow_mut().push( + Diagnostic::hint(sema.diagnostics_display_range(d).range, d.message()) + .with_unused(true), + ); + }) // Only collect experimental diagnostics when they're enabled. .filter(|diag| !(diag.is_experimental() && config.disable_experimental)) .filter(|diag| !config.disabled.contains(diag.code().as_str())); -- cgit v1.2.3