@@ -3462,52 +3462,46 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
34623462
34633463 /// This method is called after we have encountered a missing field error to recursively
34643464 /// search for the field
3465+ #[ instrument( skip( self , matches, mod_id, hir_id) , level = "debug" ) ]
34653466 pub ( crate ) fn check_for_nested_field_satisfying_condition_for_diag (
34663467 & self ,
34673468 span : Span ,
34683469 matches : & impl Fn ( Ident , Ty < ' tcx > ) -> bool ,
3469- candidate_field : ( Ident , Ty < ' tcx > ) ,
3470+ ( candidate_name , candidate_ty ) : ( Ident , Ty < ' tcx > ) ,
34703471 mut field_path : Vec < Ident > ,
34713472 mod_id : DefId ,
34723473 hir_id : HirId ,
34733474 ) -> Option < Vec < Ident > > {
3474- debug ! (
3475- "check_for_nested_field_satisfying(span: {:?}, candidate_field: {:?}, field_path: {:?}" ,
3476- span, candidate_field, field_path
3477- ) ;
3478-
34793475 if field_path. len ( ) > 3 {
34803476 // For compile-time reasons and to avoid infinite recursion we only check for fields
34813477 // up to a depth of three
3482- None
3483- } else {
3484- field_path. push ( candidate_field. 0 ) ;
3485- let field_ty = candidate_field. 1 ;
3486- if matches ( candidate_field. 0 , field_ty) {
3487- return Some ( field_path) ;
3488- } else {
3489- for nested_fields in self . get_field_candidates_considering_privacy_for_diag (
3490- span, field_ty, mod_id, hir_id,
3478+ return None ;
3479+ }
3480+ field_path. push ( candidate_name) ;
3481+ if matches ( candidate_name, candidate_ty) {
3482+ return Some ( field_path) ;
3483+ }
3484+ for nested_fields in self . get_field_candidates_considering_privacy_for_diag (
3485+ span,
3486+ candidate_ty,
3487+ mod_id,
3488+ hir_id,
3489+ ) {
3490+ // recursively search fields of `candidate_field` if it's a ty::Adt
3491+ for field in nested_fields {
3492+ if let Some ( field_path) = self . check_for_nested_field_satisfying_condition_for_diag (
3493+ span,
3494+ matches,
3495+ field,
3496+ field_path. clone ( ) ,
3497+ mod_id,
3498+ hir_id,
34913499 ) {
3492- // recursively search fields of `candidate_field` if it's a ty::Adt
3493- for field in nested_fields {
3494- if let Some ( field_path) = self
3495- . check_for_nested_field_satisfying_condition_for_diag (
3496- span,
3497- matches,
3498- field,
3499- field_path. clone ( ) ,
3500- mod_id,
3501- hir_id,
3502- )
3503- {
3504- return Some ( field_path) ;
3505- }
3506- }
3500+ return Some ( field_path) ;
35073501 }
35083502 }
3509- None
35103503 }
3504+ None
35113505 }
35123506
35133507 fn check_expr_index (
0 commit comments