@@ -608,42 +608,39 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
608
608
} ;
609
609
(
610
610
true ,
611
- td. as_local ( ) . and_then ( |tld| {
612
- let h = hir_map. local_def_id_to_hir_id ( tld) ;
613
- match hir_map. find ( h) {
614
- Some ( Node :: Item ( hir:: Item {
615
- kind : hir:: ItemKind :: Trait ( _, _, _, _, items) ,
616
- ..
617
- } ) ) => {
618
- let mut f_in_trait_opt = None ;
619
- for hir:: TraitItemRef { id : fi, kind : k, .. } in * items {
620
- let hi = fi. hir_id ( ) ;
621
- if !matches ! ( k, hir:: AssocItemKind :: Fn { .. } ) {
622
- continue ;
623
- }
624
- if hir_map. name ( hi) != hir_map. name ( my_hir) {
625
- continue ;
626
- }
627
- f_in_trait_opt = Some ( hi) ;
628
- break ;
611
+ td. as_local ( ) . and_then ( |tld| match hir_map. find_def ( tld) {
612
+ Some ( Node :: Item ( hir:: Item {
613
+ kind : hir:: ItemKind :: Trait ( _, _, _, _, items) ,
614
+ ..
615
+ } ) ) => {
616
+ let mut f_in_trait_opt = None ;
617
+ for hir:: TraitItemRef { id : fi, kind : k, .. } in * items {
618
+ let hi = fi. hir_id ( ) ;
619
+ if !matches ! ( k, hir:: AssocItemKind :: Fn { .. } ) {
620
+ continue ;
629
621
}
630
- f_in_trait_opt. and_then ( |f_in_trait| match hir_map. find ( f_in_trait) {
631
- Some ( Node :: TraitItem ( hir:: TraitItem {
632
- kind :
633
- hir:: TraitItemKind :: Fn (
634
- hir:: FnSig { decl : hir:: FnDecl { inputs, .. } , .. } ,
635
- _,
636
- ) ,
637
- ..
638
- } ) ) => {
639
- let hir:: Ty { span, .. } = inputs[ local. index ( ) - 1 ] ;
640
- Some ( span)
641
- }
642
- _ => None ,
643
- } )
622
+ if hir_map. name ( hi) != hir_map. name ( my_hir) {
623
+ continue ;
624
+ }
625
+ f_in_trait_opt = Some ( hi) ;
626
+ break ;
644
627
}
645
- _ => None ,
628
+ f_in_trait_opt. and_then ( |f_in_trait| match hir_map. find ( f_in_trait) {
629
+ Some ( Node :: TraitItem ( hir:: TraitItem {
630
+ kind :
631
+ hir:: TraitItemKind :: Fn (
632
+ hir:: FnSig { decl : hir:: FnDecl { inputs, .. } , .. } ,
633
+ _,
634
+ ) ,
635
+ ..
636
+ } ) ) => {
637
+ let hir:: Ty { span, .. } = inputs[ local. index ( ) - 1 ] ;
638
+ Some ( span)
639
+ }
640
+ _ => None ,
641
+ } )
646
642
}
643
+ _ => None ,
647
644
} ) ,
648
645
)
649
646
}
@@ -1053,8 +1050,7 @@ fn annotate_struct_field(
1053
1050
if let ty:: Adt ( def, _) = ty. kind ( ) {
1054
1051
let field = def. all_fields ( ) . nth ( field. index ( ) ) ?;
1055
1052
// Use the HIR types to construct the diagnostic message.
1056
- let hir_id = tcx. hir ( ) . local_def_id_to_hir_id ( field. did . as_local ( ) ?) ;
1057
- let node = tcx. hir ( ) . find ( hir_id) ?;
1053
+ let node = tcx. hir ( ) . find_def ( field. did . as_local ( ) ?) ?;
1058
1054
// Now we're dealing with the actual struct that we're going to suggest a change to,
1059
1055
// we can expect a field that is an immutable reference to a type.
1060
1056
if let hir:: Node :: Field ( field) = node {
0 commit comments