@@ -3462,52 +3462,46 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
3462
3462
3463
3463
/// This method is called after we have encountered a missing field error to recursively
3464
3464
/// search for the field
3465
+ #[ instrument( skip( self , matches, mod_id, hir_id) , level = "debug" ) ]
3465
3466
pub ( crate ) fn check_for_nested_field_satisfying_condition_for_diag (
3466
3467
& self ,
3467
3468
span : Span ,
3468
3469
matches : & impl Fn ( Ident , Ty < ' tcx > ) -> bool ,
3469
- candidate_field : ( Ident , Ty < ' tcx > ) ,
3470
+ ( candidate_name , candidate_ty ) : ( Ident , Ty < ' tcx > ) ,
3470
3471
mut field_path : Vec < Ident > ,
3471
3472
mod_id : DefId ,
3472
3473
hir_id : HirId ,
3473
3474
) -> Option < Vec < Ident > > {
3474
- debug ! (
3475
- "check_for_nested_field_satisfying(span: {:?}, candidate_field: {:?}, field_path: {:?}" ,
3476
- span, candidate_field, field_path
3477
- ) ;
3478
-
3479
3475
if field_path. len ( ) > 3 {
3480
3476
// For compile-time reasons and to avoid infinite recursion we only check for fields
3481
3477
// 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,
3491
3499
) {
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) ;
3507
3501
}
3508
3502
}
3509
- None
3510
3503
}
3504
+ None
3511
3505
}
3512
3506
3513
3507
fn check_expr_index (
0 commit comments