aboutsummaryrefslogtreecommitdiff
path: root/crates/hir_expand
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2020-08-18 17:39:43 +0100
committerAleksey Kladov <[email protected]>2020-08-18 17:39:43 +0100
commit8146669542dfc887956901b54a453c9a97fee7e3 (patch)
tree4408709203c98b63df20204a5630db86914f2e94 /crates/hir_expand
parentbbb1c617b9198c230d8331dc0ffc2affb01d2e7a (diff)
Add type safety to diagnostic codes
Diffstat (limited to 'crates/hir_expand')
-rw-r--r--crates/hir_expand/src/diagnostics.rs11
1 files changed, 10 insertions, 1 deletions
diff --git a/crates/hir_expand/src/diagnostics.rs b/crates/hir_expand/src/diagnostics.rs
index 6c81b2501..78ccc212c 100644
--- a/crates/hir_expand/src/diagnostics.rs
+++ b/crates/hir_expand/src/diagnostics.rs
@@ -20,8 +20,17 @@ use syntax::SyntaxNodePtr;
20 20
21use crate::InFile; 21use crate::InFile;
22 22
23#[derive(Copy, Clone, PartialEq)]
24pub struct DiagnosticCode(pub &'static str);
25
26impl DiagnosticCode {
27 pub fn as_str(&self) -> &str {
28 self.0
29 }
30}
31
23pub trait Diagnostic: Any + Send + Sync + fmt::Debug + 'static { 32pub trait Diagnostic: Any + Send + Sync + fmt::Debug + 'static {
24 fn name(&self) -> &'static str; 33 fn code(&self) -> DiagnosticCode;
25 fn message(&self) -> String; 34 fn message(&self) -> String;
26 /// Used in highlighting and related purposes 35 /// Used in highlighting and related purposes
27 fn display_source(&self) -> InFile<SyntaxNodePtr>; 36 fn display_source(&self) -> InFile<SyntaxNodePtr>;