diff options
author | Aleksey Kladov <[email protected]> | 2021-06-12 15:17:23 +0100 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2021-06-12 15:17:23 +0100 |
commit | f8009666beaedb34197da9c87cc54d8ca65203b8 (patch) | |
tree | 673322cf9a916270a2d20ccc35a5e62796ce812f /crates/hir/src/lib.rs | |
parent | 409f5fb563bfc992e4d05245d5c17e77ff8e2762 (diff) |
internal: move inference diagnostics to hir
Diffstat (limited to 'crates/hir/src/lib.rs')
-rw-r--r-- | crates/hir/src/lib.rs | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/crates/hir/src/lib.rs b/crates/hir/src/lib.rs index 0bb3767c1..bce626b03 100644 --- a/crates/hir/src/lib.rs +++ b/crates/hir/src/lib.rs | |||
@@ -36,8 +36,9 @@ use std::{iter, sync::Arc}; | |||
36 | use arrayvec::ArrayVec; | 36 | use arrayvec::ArrayVec; |
37 | use base_db::{CrateDisplayName, CrateId, Edition, FileId}; | 37 | use base_db::{CrateDisplayName, CrateId, Edition, FileId}; |
38 | use diagnostics::{ | 38 | use diagnostics::{ |
39 | InactiveCode, MacroError, UnimplementedBuiltinMacro, UnresolvedExternCrate, UnresolvedImport, | 39 | BreakOutsideOfLoop, InactiveCode, MacroError, NoSuchField, UnimplementedBuiltinMacro, |
40 | UnresolvedMacroCall, UnresolvedModule, UnresolvedProcMacro, | 40 | UnresolvedExternCrate, UnresolvedImport, UnresolvedMacroCall, UnresolvedModule, |
41 | UnresolvedProcMacro, | ||
41 | }; | 42 | }; |
42 | use either::Either; | 43 | use either::Either; |
43 | use hir_def::{ | 44 | use hir_def::{ |
@@ -1042,6 +1043,23 @@ impl Function { | |||
1042 | } | 1043 | } |
1043 | } | 1044 | } |
1044 | 1045 | ||
1046 | let infer = db.infer(self.id.into()); | ||
1047 | let (_, source_map) = db.body_with_source_map(self.id.into()); | ||
1048 | for d in &infer.diagnostics { | ||
1049 | match d { | ||
1050 | hir_ty::InferenceDiagnostic::NoSuchField { expr } => { | ||
1051 | let field = source_map.field_syntax(*expr); | ||
1052 | sink.push(NoSuchField { file: field.file_id, field: field.value }) | ||
1053 | } | ||
1054 | hir_ty::InferenceDiagnostic::BreakOutsideOfLoop { expr } => { | ||
1055 | let ptr = source_map | ||
1056 | .expr_syntax(*expr) | ||
1057 | .expect("break outside of loop in synthetic syntax"); | ||
1058 | sink.push(BreakOutsideOfLoop { file: ptr.file_id, expr: ptr.value }) | ||
1059 | } | ||
1060 | } | ||
1061 | } | ||
1062 | |||
1045 | hir_ty::diagnostics::validate_module_item(db, krate, self.id.into(), sink); | 1063 | hir_ty::diagnostics::validate_module_item(db, krate, self.id.into(), sink); |
1046 | hir_ty::diagnostics::validate_body(db, self.id.into(), sink); | 1064 | hir_ty::diagnostics::validate_body(db, self.id.into(), sink); |
1047 | } | 1065 | } |