aboutsummaryrefslogtreecommitdiff
path: root/crates/hir/src/lib.rs
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2021-06-13 13:27:15 +0100
committerAleksey Kladov <[email protected]>2021-06-13 13:27:15 +0100
commitc6509a4592b67acc4a99a7ffd6dd688bc6cd29be (patch)
treed174244c1e35cc91a98d1aced254a560079e48c5 /crates/hir/src/lib.rs
parentefa069d28818dd074afd2c7cee776907b63ca012 (diff)
internal: move missing_fields diagnostics
Diffstat (limited to 'crates/hir/src/lib.rs')
-rw-r--r--crates/hir/src/lib.rs33
1 files changed, 18 insertions, 15 deletions
diff --git a/crates/hir/src/lib.rs b/crates/hir/src/lib.rs
index ff6c68dbc..583d92f20 100644
--- a/crates/hir/src/lib.rs
+++ b/crates/hir/src/lib.rs
@@ -609,23 +609,21 @@ impl Module {
609 } 609 }
610 for decl in self.declarations(db) { 610 for decl in self.declarations(db) {
611 match decl { 611 match decl {
612 crate::ModuleDef::Function(f) => f.diagnostics(db, sink, internal_diagnostics), 612 ModuleDef::Function(f) => acc.extend(f.diagnostics(db, sink, internal_diagnostics)),
613 crate::ModuleDef::Module(m) => { 613 ModuleDef::Module(m) => {
614 // Only add diagnostics from inline modules 614 // Only add diagnostics from inline modules
615 if def_map[m.id.local_id].origin.is_inline() { 615 if def_map[m.id.local_id].origin.is_inline() {
616 acc.extend(m.diagnostics(db, sink, internal_diagnostics)) 616 acc.extend(m.diagnostics(db, sink, internal_diagnostics))
617 } 617 }
618 } 618 }
619 _ => { 619 _ => decl.diagnostics(db, sink),
620 decl.diagnostics(db, sink);
621 }
622 } 620 }
623 } 621 }
624 622
625 for impl_def in self.impl_defs(db) { 623 for impl_def in self.impl_defs(db) {
626 for item in impl_def.items(db) { 624 for item in impl_def.items(db) {
627 if let AssocItem::Function(f) = item { 625 if let AssocItem::Function(f) = item {
628 f.diagnostics(db, sink, internal_diagnostics); 626 acc.extend(f.diagnostics(db, sink, internal_diagnostics));
629 } 627 }
630 } 628 }
631 } 629 }
@@ -1033,7 +1031,8 @@ impl Function {
1033 db: &dyn HirDatabase, 1031 db: &dyn HirDatabase,
1034 sink: &mut DiagnosticSink, 1032 sink: &mut DiagnosticSink,
1035 internal_diagnostics: bool, 1033 internal_diagnostics: bool,
1036 ) { 1034 ) -> Vec<AnyDiagnostic> {
1035 let mut acc: Vec<AnyDiagnostic> = Vec::new();
1037 let krate = self.module(db).id.krate(); 1036 let krate = self.module(db).id.krate();
1038 1037
1039 let source_map = db.body_with_source_map(self.id.into()).1; 1038 let source_map = db.body_with_source_map(self.id.into()).1;
@@ -1114,14 +1113,17 @@ impl Function {
1114 .into_iter() 1113 .into_iter()
1115 .map(|idx| variant_data.fields()[idx].name.clone()) 1114 .map(|idx| variant_data.fields()[idx].name.clone())
1116 .collect(); 1115 .collect();
1117 sink.push(MissingFields { 1116 acc.push(
1118 file: source_ptr.file_id, 1117 MissingFields {
1119 field_list_parent: AstPtr::new(record_expr), 1118 file: source_ptr.file_id,
1120 field_list_parent_path: record_expr 1119 field_list_parent: AstPtr::new(record_expr),
1121 .path() 1120 field_list_parent_path: record_expr
1122 .map(|path| AstPtr::new(&path)), 1121 .path()
1123 missed_fields, 1122 .map(|path| AstPtr::new(&path)),
1124 }) 1123 missed_fields,
1124 }
1125 .into(),
1126 )
1125 } 1127 }
1126 } 1128 }
1127 } 1129 }
@@ -1234,6 +1236,7 @@ impl Function {
1234 for diag in hir_ty::diagnostics::validate_module_item(db, krate, self.id.into()) { 1236 for diag in hir_ty::diagnostics::validate_module_item(db, krate, self.id.into()) {
1235 sink.push(diag) 1237 sink.push(diag)
1236 } 1238 }
1239 acc
1237 } 1240 }
1238 1241
1239 /// Whether this function declaration has a definition. 1242 /// Whether this function declaration has a definition.