From 66f04e6be54c47104877bff777b7042960d04393 Mon Sep 17 00:00:00 2001 From: Frizi Date: Sun, 24 Nov 2019 17:36:30 +0100 Subject: Show missing struct fields in the error message --- crates/ra_hir/src/diagnostics.rs | 7 ++++++- crates/ra_hir/src/ty/tests.rs | 3 ++- 2 files changed, 8 insertions(+), 2 deletions(-) (limited to 'crates/ra_hir') diff --git a/crates/ra_hir/src/diagnostics.rs b/crates/ra_hir/src/diagnostics.rs index dafacba70..6db499e06 100644 --- a/crates/ra_hir/src/diagnostics.rs +++ b/crates/ra_hir/src/diagnostics.rs @@ -39,7 +39,12 @@ pub struct MissingFields { impl Diagnostic for MissingFields { fn message(&self) -> String { - "fill structure fields".to_string() + use std::fmt::Write; + let mut message = String::from("Missing structure fields:\n"); + for field in &self.missed_fields { + write!(message, "- {}\n", field).unwrap(); + } + message } fn source(&self) -> Source { Source { file_id: self.file, value: self.field_list.into() } diff --git a/crates/ra_hir/src/ty/tests.rs b/crates/ra_hir/src/ty/tests.rs index 3209c66bd..98eb863cb 100644 --- a/crates/ra_hir/src/ty/tests.rs +++ b/crates/ra_hir/src/ty/tests.rs @@ -4832,7 +4832,8 @@ fn no_such_field_diagnostics() { assert_snapshot!(diagnostics, @r###" "baz: 62": no such field - "{\n foo: 92,\n baz: 62,\n }": fill structure fields + "{\n foo: 92,\n baz: 62,\n }": Missing structure fields: + - bar "### ); } -- cgit v1.2.3