Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/hir/src/diagnostics.rs')
| -rw-r--r-- | crates/hir/src/diagnostics.rs | 26 |
1 files changed, 9 insertions, 17 deletions
diff --git a/crates/hir/src/diagnostics.rs b/crates/hir/src/diagnostics.rs index 651ec151d4..656f350039 100644 --- a/crates/hir/src/diagnostics.rs +++ b/crates/hir/src/diagnostics.rs @@ -7,12 +7,10 @@ use cfg::{CfgExpr, CfgOptions}; use either::Either; use hir_def::{ DefWithBodyId, SyntheticSyntax, - expr_store::ExprOrPatPtr, + expr_store::{ExprOrPatPtr, ExpressionStoreSourceMap, hir_segment_to_ast_segment}, hir::ExprOrPatId, - path::{ModPath, hir_segment_to_ast_segment}, - type_ref::TypesSourceMap, }; -use hir_expand::{HirFileId, InFile, name::Name}; +use hir_expand::{HirFileId, InFile, mod_path::ModPath, name::Name}; use hir_ty::{ CastError, InferenceDiagnostic, InferenceTyDiagnosticSource, PathLoweringDiagnostic, TyLoweringDiagnostic, TyLoweringDiagnosticKind, @@ -566,8 +564,8 @@ impl AnyDiagnostic { db: &dyn HirDatabase, def: DefWithBodyId, d: &InferenceDiagnostic, - outer_types_source_map: &TypesSourceMap, source_map: &hir_def::expr_store::BodySourceMap, + sig_map: &hir_def::expr_store::ExpressionStoreSourceMap, ) -> Option<AnyDiagnostic> { let expr_syntax = |expr| { source_map @@ -696,8 +694,8 @@ impl AnyDiagnostic { } InferenceDiagnostic::TyDiagnostic { source, diag } => { let source_map = match source { - InferenceTyDiagnosticSource::Body => &source_map.types, - InferenceTyDiagnosticSource::Signature => outer_types_source_map, + InferenceTyDiagnosticSource::Body => source_map, + InferenceTyDiagnosticSource::Signature => sig_map, }; Self::ty_diagnostic(diag, source_map, db)? } @@ -757,18 +755,12 @@ impl AnyDiagnostic { pub(crate) fn ty_diagnostic( diag: &TyLoweringDiagnostic, - source_map: &TypesSourceMap, + source_map: &ExpressionStoreSourceMap, db: &dyn HirDatabase, ) -> Option<AnyDiagnostic> { - let source = match diag.source { - Either::Left(type_ref_id) => { - let Ok(source) = source_map.type_syntax(type_ref_id) else { - stdx::never!("error on synthetic type syntax"); - return None; - }; - source - } - Either::Right(source) => source, + let Ok(source) = source_map.type_syntax(diag.source) else { + stdx::never!("error on synthetic type syntax"); + return None; }; let syntax = || source.value.to_node(&db.parse_or_expand(source.file_id)); Some(match &diag.kind { |