@@ -88,9 +88,9 @@ pub use crate::{
8888 diagnostics:: {
8989 AnyDiagnostic , BreakOutsideOfLoop , InactiveCode , InternalBailedOut , MacroError ,
9090 MismatchedArgCount , MissingFields , MissingMatchArms , MissingOkOrSomeInTailExpr ,
91- MissingPatFields , MissingUnsafe , NoSuchField , RemoveThisSemicolon ,
92- ReplaceFilterMapNextWithFindMap , UnimplementedBuiltinMacro , UnresolvedExternCrate ,
93- UnresolvedImport , UnresolvedMacroCall , UnresolvedModule , UnresolvedProcMacro ,
91+ MissingUnsafe , NoSuchField , RemoveThisSemicolon , ReplaceFilterMapNextWithFindMap ,
92+ UnimplementedBuiltinMacro , UnresolvedExternCrate , UnresolvedImport , UnresolvedMacroCall ,
93+ UnresolvedModule , UnresolvedProcMacro ,
9494 } ,
9595 has_source:: HasSource ,
9696 semantics:: { PathResolution , Semantics , SemanticsScope } ,
@@ -1098,67 +1098,70 @@ impl Function {
10981098 BodyValidationDiagnostic :: collect ( db, self . id . into ( ) , internal_diagnostics)
10991099 {
11001100 match diagnostic {
1101- BodyValidationDiagnostic :: RecordLiteralMissingFields {
1102- record_expr ,
1101+ BodyValidationDiagnostic :: RecordMissingFields {
1102+ record ,
11031103 variant,
11041104 missed_fields,
1105- } => match source_map. expr_syntax ( record_expr) {
1106- Ok ( source_ptr) => {
1107- let root = source_ptr. file_syntax ( db. upcast ( ) ) ;
1108- if let ast:: Expr :: RecordExpr ( record_expr) = & source_ptr. value . to_node ( & root)
1109- {
1110- if let Some ( _) = record_expr. record_expr_field_list ( ) {
1111- let variant_data = variant. variant_data ( db. upcast ( ) ) ;
1112- let missed_fields = missed_fields
1113- . into_iter ( )
1114- . map ( |idx| variant_data. fields ( ) [ idx] . name . clone ( ) )
1115- . collect ( ) ;
1116- acc. push (
1117- MissingFields {
1118- file : source_ptr. file_id ,
1119- field_list_parent : AstPtr :: new ( record_expr) ,
1120- field_list_parent_path : record_expr
1121- . path ( )
1122- . map ( |path| AstPtr :: new ( & path) ) ,
1123- missed_fields,
1105+ } => {
1106+ let variant_data = variant. variant_data ( db. upcast ( ) ) ;
1107+ let missed_fields = missed_fields
1108+ . into_iter ( )
1109+ . map ( |idx| variant_data. fields ( ) [ idx] . name . clone ( ) )
1110+ . collect ( ) ;
1111+
1112+ match record {
1113+ Either :: Left ( record_expr) => match source_map. expr_syntax ( record_expr) {
1114+ Ok ( source_ptr) => {
1115+ let root = source_ptr. file_syntax ( db. upcast ( ) ) ;
1116+ if let ast:: Expr :: RecordExpr ( record_expr) =
1117+ & source_ptr. value . to_node ( & root)
1118+ {
1119+ if let Some ( _) = record_expr. record_expr_field_list ( ) {
1120+ acc. push (
1121+ MissingFields {
1122+ file : source_ptr. file_id ,
1123+ field_list_parent : Either :: Left ( AstPtr :: new (
1124+ record_expr,
1125+ ) ) ,
1126+ field_list_parent_path : record_expr
1127+ . path ( )
1128+ . map ( |path| AstPtr :: new ( & path) ) ,
1129+ missed_fields,
1130+ }
1131+ . into ( ) ,
1132+ )
11241133 }
1125- . into ( ) ,
1126- )
1134+ }
11271135 }
1128- }
1129- }
1130- Err ( SyntheticSyntax ) => ( ) ,
1131- } ,
1132- BodyValidationDiagnostic :: RecordPatMissingFields {
1133- record_pat,
1134- variant,
1135- missed_fields,
1136- } => match source_map. pat_syntax ( record_pat) {
1137- Ok ( source_ptr) => {
1138- if let Some ( expr) = source_ptr. value . as_ref ( ) . left ( ) {
1139- let root = source_ptr. file_syntax ( db. upcast ( ) ) ;
1140- if let ast:: Pat :: RecordPat ( record_pat) = expr. to_node ( & root) {
1141- if let Some ( _) = record_pat. record_pat_field_list ( ) {
1142- let variant_data = variant. variant_data ( db. upcast ( ) ) ;
1143- let missed_fields = missed_fields
1144- . into_iter ( )
1145- . map ( |idx| variant_data. fields ( ) [ idx] . name . clone ( ) )
1146- . collect ( ) ;
1147- sink. push ( MissingPatFields {
1148- file : source_ptr. file_id ,
1149- field_list_parent : AstPtr :: new ( & record_pat) ,
1150- field_list_parent_path : record_pat
1151- . path ( )
1152- . map ( |path| AstPtr :: new ( & path) ) ,
1153- missed_fields,
1154- } )
1136+ Err ( SyntheticSyntax ) => ( ) ,
1137+ } ,
1138+ Either :: Right ( record_pat) => match source_map. pat_syntax ( record_pat) {
1139+ Ok ( source_ptr) => {
1140+ if let Some ( expr) = source_ptr. value . as_ref ( ) . left ( ) {
1141+ let root = source_ptr. file_syntax ( db. upcast ( ) ) ;
1142+ if let ast:: Pat :: RecordPat ( record_pat) = expr. to_node ( & root) {
1143+ if let Some ( _) = record_pat. record_pat_field_list ( ) {
1144+ acc. push (
1145+ MissingFields {
1146+ file : source_ptr. file_id ,
1147+ field_list_parent : Either :: Right ( AstPtr :: new (
1148+ & record_pat,
1149+ ) ) ,
1150+ field_list_parent_path : record_pat
1151+ . path ( )
1152+ . map ( |path| AstPtr :: new ( & path) ) ,
1153+ missed_fields,
1154+ }
1155+ . into ( ) ,
1156+ )
1157+ }
1158+ }
11551159 }
11561160 }
1157- }
1161+ Err ( SyntheticSyntax ) => ( ) ,
1162+ } ,
11581163 }
1159- Err ( SyntheticSyntax ) => ( ) ,
1160- } ,
1161-
1164+ }
11621165 BodyValidationDiagnostic :: ReplaceFilterMapNextWithFindMap { method_call_expr } => {
11631166 if let Ok ( next_source_ptr) = source_map. expr_syntax ( method_call_expr) {
11641167 sink. push ( ReplaceFilterMapNextWithFindMap {
0 commit comments