@@ -9,6 +9,7 @@ use hir_ty::{db::HirDatabase, diagnostics::BodyValidationDiagnostic, InferenceDi
99use base_db:: CrateId ;
1010use cfg:: { CfgExpr , CfgOptions } ;
1111use either:: Either ;
12+ pub use hir_def:: VariantId ;
1213use hir_def:: { body:: SyntheticSyntax , hir:: ExprOrPatId , path:: ModPath , AssocItemId , DefWithBodyId } ;
1314use hir_expand:: { name:: Name , HirFileId , InFile } ;
1415use syntax:: { ast, AstPtr , SyntaxError , SyntaxNodePtr , TextRange } ;
@@ -200,6 +201,7 @@ pub struct MalformedDerive {
200201pub struct NoSuchField {
201202 pub field : InFile < AstPtr < Either < ast:: RecordExprField , ast:: RecordPatField > > > ,
202203 pub private : bool ,
204+ pub variant : VariantId ,
203205}
204206
205207#[ derive( Debug ) ]
@@ -525,7 +527,7 @@ impl AnyDiagnostic {
525527 source_map. pat_syntax ( pat) . inspect_err ( |_| tracing:: error!( "synthetic syntax" ) ) . ok ( )
526528 } ;
527529 Some ( match d {
528- & InferenceDiagnostic :: NoSuchField { field : expr, private } => {
530+ & InferenceDiagnostic :: NoSuchField { field : expr, private, variant } => {
529531 let expr_or_pat = match expr {
530532 ExprOrPatId :: ExprId ( expr) => {
531533 source_map. field_syntax ( expr) . map ( AstPtr :: wrap_left)
@@ -534,7 +536,7 @@ impl AnyDiagnostic {
534536 source_map. pat_field_syntax ( pat) . map ( AstPtr :: wrap_right)
535537 }
536538 } ;
537- NoSuchField { field : expr_or_pat, private } . into ( )
539+ NoSuchField { field : expr_or_pat, private, variant } . into ( )
538540 }
539541 & InferenceDiagnostic :: MismatchedArgCount { call_expr, expected, found } => {
540542 MismatchedArgCount { call_expr : expr_syntax ( call_expr) ?, expected, found } . into ( )
0 commit comments