mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-29 05:15:04 +00:00
internal: move inference diagnostics to hir
This commit is contained in:
parent
409f5fb563
commit
f8009666be
6 changed files with 222 additions and 244 deletions
|
@ -36,8 +36,9 @@ use std::{iter, sync::Arc};
|
|||
use arrayvec::ArrayVec;
|
||||
use base_db::{CrateDisplayName, CrateId, Edition, FileId};
|
||||
use diagnostics::{
|
||||
InactiveCode, MacroError, UnimplementedBuiltinMacro, UnresolvedExternCrate, UnresolvedImport,
|
||||
UnresolvedMacroCall, UnresolvedModule, UnresolvedProcMacro,
|
||||
BreakOutsideOfLoop, InactiveCode, MacroError, NoSuchField, UnimplementedBuiltinMacro,
|
||||
UnresolvedExternCrate, UnresolvedImport, UnresolvedMacroCall, UnresolvedModule,
|
||||
UnresolvedProcMacro,
|
||||
};
|
||||
use either::Either;
|
||||
use hir_def::{
|
||||
|
@ -1042,6 +1043,23 @@ impl Function {
|
|||
}
|
||||
}
|
||||
|
||||
let infer = db.infer(self.id.into());
|
||||
let (_, source_map) = db.body_with_source_map(self.id.into());
|
||||
for d in &infer.diagnostics {
|
||||
match d {
|
||||
hir_ty::InferenceDiagnostic::NoSuchField { expr } => {
|
||||
let field = source_map.field_syntax(*expr);
|
||||
sink.push(NoSuchField { file: field.file_id, field: field.value })
|
||||
}
|
||||
hir_ty::InferenceDiagnostic::BreakOutsideOfLoop { expr } => {
|
||||
let ptr = source_map
|
||||
.expr_syntax(*expr)
|
||||
.expect("break outside of loop in synthetic syntax");
|
||||
sink.push(BreakOutsideOfLoop { file: ptr.file_id, expr: ptr.value })
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
hir_ty::diagnostics::validate_module_item(db, krate, self.id.into(), sink);
|
||||
hir_ty::diagnostics::validate_body(db, self.id.into(), sink);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue