aboutsummaryrefslogtreecommitdiff
path: root/crates/hir_def/src/diagnostics.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/hir_def/src/diagnostics.rs')
-rw-r--r--crates/hir_def/src/diagnostics.rs14
1 files changed, 12 insertions, 2 deletions
diff --git a/crates/hir_def/src/diagnostics.rs b/crates/hir_def/src/diagnostics.rs
index c9c08b01f..34a6a8d4b 100644
--- a/crates/hir_def/src/diagnostics.rs
+++ b/crates/hir_def/src/diagnostics.rs
@@ -1,7 +1,9 @@
1//! Diagnostics produced by `hir_def`. 1//! Diagnostics produced by `hir_def`.
2 2
3use std::any::Any; 3use std::any::Any;
4use std::fmt::Write;
4 5
6use cfg::{CfgExpr, CfgOptions, DnfExpr};
5use hir_expand::diagnostics::{Diagnostic, DiagnosticCode}; 7use hir_expand::diagnostics::{Diagnostic, DiagnosticCode};
6use syntax::{ast, AstPtr, SyntaxNodePtr}; 8use syntax::{ast, AstPtr, SyntaxNodePtr};
7 9
@@ -94,6 +96,8 @@ impl Diagnostic for UnresolvedImport {
94pub struct InactiveCode { 96pub struct InactiveCode {
95 pub file: HirFileId, 97 pub file: HirFileId,
96 pub node: SyntaxNodePtr, 98 pub node: SyntaxNodePtr,
99 pub cfg: CfgExpr,
100 pub opts: CfgOptions,
97} 101}
98 102
99impl Diagnostic for InactiveCode { 103impl Diagnostic for InactiveCode {
@@ -101,8 +105,14 @@ impl Diagnostic for InactiveCode {
101 DiagnosticCode("inactive-code") 105 DiagnosticCode("inactive-code")
102 } 106 }
103 fn message(&self) -> String { 107 fn message(&self) -> String {
104 // FIXME: say *why* it is configured out 108 let inactive = DnfExpr::new(self.cfg.clone()).why_inactive(&self.opts);
105 "code is inactive due to #[cfg] directives".to_string() 109 let mut buf = "code is inactive due to #[cfg] directives".to_string();
110
111 if let Some(inactive) = inactive {
112 write!(buf, ": {}", inactive).unwrap();
113 }
114
115 buf
106 } 116 }
107 fn display_source(&self) -> InFile<SyntaxNodePtr> { 117 fn display_source(&self) -> InFile<SyntaxNodePtr> {
108 InFile::new(self.file, self.node.clone()) 118 InFile::new(self.file, self.node.clone())