aboutsummaryrefslogtreecommitdiff
path: root/crates/hir/src/diagnostics.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/hir/src/diagnostics.rs')
-rw-r--r--crates/hir/src/diagnostics.rs43
1 files changed, 2 insertions, 41 deletions
diff --git a/crates/hir/src/diagnostics.rs b/crates/hir/src/diagnostics.rs
index 5e2f94698..a5e982b75 100644
--- a/crates/hir/src/diagnostics.rs
+++ b/crates/hir/src/diagnostics.rs
@@ -16,7 +16,7 @@ pub use crate::diagnostics_sink::{
16}; 16};
17 17
18macro_rules! diagnostics { 18macro_rules! diagnostics {
19 ($($diag:ident)*) => { 19 ($($diag:ident),*) => {
20 pub enum AnyDiagnostic {$( 20 pub enum AnyDiagnostic {$(
21 $diag(Box<$diag>), 21 $diag(Box<$diag>),
22 )*} 22 )*}
@@ -31,7 +31,7 @@ macro_rules! diagnostics {
31 }; 31 };
32} 32}
33 33
34diagnostics![UnresolvedModule]; 34diagnostics![UnresolvedModule, MissingFields];
35 35
36#[derive(Debug)] 36#[derive(Debug)]
37pub struct UnresolvedModule { 37pub struct UnresolvedModule {
@@ -321,17 +321,6 @@ impl Diagnostic for MissingUnsafe {
321 } 321 }
322} 322}
323 323
324// Diagnostic: missing-structure-fields
325//
326// This diagnostic is triggered if record lacks some fields that exist in the corresponding structure.
327//
328// Example:
329//
330// ```rust
331// struct A { a: u8, b: u8 }
332//
333// let a = A { a: 10 };
334// ```
335#[derive(Debug)] 324#[derive(Debug)]
336pub struct MissingFields { 325pub struct MissingFields {
337 pub file: HirFileId, 326 pub file: HirFileId,
@@ -340,34 +329,6 @@ pub struct MissingFields {
340 pub missed_fields: Vec<Name>, 329 pub missed_fields: Vec<Name>,
341} 330}
342 331
343impl Diagnostic for MissingFields {
344 fn code(&self) -> DiagnosticCode {
345 DiagnosticCode("missing-structure-fields")
346 }
347 fn message(&self) -> String {
348 let mut buf = String::from("Missing structure fields:\n");
349 for field in &self.missed_fields {
350 format_to!(buf, "- {}\n", field);
351 }
352 buf
353 }
354
355 fn display_source(&self) -> InFile<SyntaxNodePtr> {
356 InFile {
357 file_id: self.file,
358 value: self
359 .field_list_parent_path
360 .clone()
361 .map(SyntaxNodePtr::from)
362 .unwrap_or_else(|| self.field_list_parent.clone().into()),
363 }
364 }
365
366 fn as_any(&self) -> &(dyn Any + Send + 'static) {
367 self
368 }
369}
370
371// Diagnostic: missing-pat-fields 332// Diagnostic: missing-pat-fields
372// 333//
373// This diagnostic is triggered if pattern lacks some fields that exist in the corresponding structure. 334// This diagnostic is triggered if pattern lacks some fields that exist in the corresponding structure.