@@ -298,7 +298,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
298
298
let hir:: Node :: Pat ( pat) = self . tcx . hir_node ( local_hir_id) else {
299
299
return false ;
300
300
} ;
301
- let ( init_ty_hir_id, init) = match hir . get_parent ( pat. hir_id ) {
301
+ let ( init_ty_hir_id, init) = match self . tcx . parent_hir_node ( pat. hir_id ) {
302
302
hir:: Node :: Local ( hir:: Local { ty : Some ( ty) , init, .. } ) => ( ty. hir_id , * init) ,
303
303
hir:: Node :: Local ( hir:: Local { init : Some ( init) , .. } ) => ( init. hir_id , Some ( * init) ) ,
304
304
_ => return false ,
@@ -445,7 +445,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
445
445
continue ;
446
446
}
447
447
448
- if let hir:: Node :: Expr ( parent_expr) = hir . get_parent ( binding. hir_id )
448
+ if let hir:: Node :: Expr ( parent_expr) = self . tcx . parent_hir_node ( binding. hir_id )
449
449
&& let hir:: ExprKind :: MethodCall ( segment, rcvr, args, _) = parent_expr. kind
450
450
&& rcvr. hir_id == binding. hir_id
451
451
{
@@ -557,7 +557,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
557
557
let Some ( TypeError :: Sorts ( ExpectedFound { expected, .. } ) ) = error else {
558
558
return ;
559
559
} ;
560
- let mut parent_id = self . tcx . hir ( ) . parent_id ( expr. hir_id ) ;
560
+ let mut parent_id = self . tcx . parent_hir_id ( expr. hir_id ) ;
561
561
let mut parent;
562
562
' outer: loop {
563
563
// Climb the HIR tree to see if the current `Expr` is part of a `break;` statement.
@@ -568,7 +568,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
568
568
break ;
569
569
} ;
570
570
parent = p;
571
- parent_id = self . tcx . hir ( ) . parent_id ( parent_id) ;
571
+ parent_id = self . tcx . parent_hir_id ( parent_id) ;
572
572
let hir:: ExprKind :: Break ( destination, _) = parent. kind else {
573
573
continue ;
574
574
} ;
@@ -578,19 +578,19 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
578
578
// Climb the HIR tree to find the (desugared) `loop` this `break` corresponds to.
579
579
let parent = match self . tcx . hir_node ( parent_id) {
580
580
hir:: Node :: Expr ( & ref parent) => {
581
- parent_id = self . tcx . hir ( ) . parent_id ( parent. hir_id ) ;
581
+ parent_id = self . tcx . parent_hir_id ( parent. hir_id ) ;
582
582
parent
583
583
}
584
584
hir:: Node :: Stmt ( hir:: Stmt {
585
585
hir_id,
586
586
kind : hir:: StmtKind :: Semi ( & ref parent) | hir:: StmtKind :: Expr ( & ref parent) ,
587
587
..
588
588
} ) => {
589
- parent_id = self . tcx . hir ( ) . parent_id ( * hir_id) ;
589
+ parent_id = self . tcx . parent_hir_id ( * hir_id) ;
590
590
parent
591
591
}
592
592
hir:: Node :: Block ( _) => {
593
- parent_id = self . tcx . hir ( ) . parent_id ( parent_id) ;
593
+ parent_id = self . tcx . parent_hir_id ( parent_id) ;
594
594
parent
595
595
}
596
596
_ => break ,
@@ -677,8 +677,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
677
677
expr : & hir:: Expr < ' _ > ,
678
678
error : Option < TypeError < ' tcx > > ,
679
679
) {
680
- let parent = self . tcx . hir ( ) . parent_id ( expr. hir_id ) ;
681
- match ( self . tcx . hir_node ( parent) , error) {
680
+ match ( self . tcx . parent_hir_node ( expr. hir_id ) , error) {
682
681
( hir:: Node :: Local ( hir:: Local { ty : Some ( ty) , init : Some ( init) , .. } ) , _)
683
682
if init. hir_id == expr. hir_id =>
684
683
{
@@ -724,16 +723,16 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
724
723
if let hir:: Node :: Pat ( pat) = self . tcx . hir_node ( * hir_id) {
725
724
primary_span = pat. span ;
726
725
secondary_span = pat. span ;
727
- match self . tcx . hir ( ) . find_parent ( pat. hir_id ) {
728
- Some ( hir:: Node :: Local ( hir:: Local { ty : Some ( ty) , .. } ) ) => {
726
+ match self . tcx . parent_hir_node ( pat. hir_id ) {
727
+ hir:: Node :: Local ( hir:: Local { ty : Some ( ty) , .. } ) => {
729
728
primary_span = ty. span ;
730
729
post_message = " type" ;
731
730
}
732
- Some ( hir:: Node :: Local ( hir:: Local { init : Some ( init) , .. } ) ) => {
731
+ hir:: Node :: Local ( hir:: Local { init : Some ( init) , .. } ) => {
733
732
primary_span = init. span ;
734
733
post_message = " value" ;
735
734
}
736
- Some ( hir:: Node :: Param ( hir:: Param { ty_span, .. } ) ) => {
735
+ hir:: Node :: Param ( hir:: Param { ty_span, .. } ) => {
737
736
primary_span = * ty_span;
738
737
post_message = " parameter type" ;
739
738
}
@@ -787,12 +786,11 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
787
786
expr : & hir:: Expr < ' _ > ,
788
787
error : Option < TypeError < ' tcx > > ,
789
788
) {
790
- let parent = self . tcx . hir ( ) . parent_id ( expr. hir_id ) ;
791
789
let Some ( TypeError :: Sorts ( ExpectedFound { expected, .. } ) ) = error else {
792
790
return ;
793
791
} ;
794
792
let hir:: Node :: Expr ( hir:: Expr { kind : hir:: ExprKind :: Assign ( lhs, rhs, _) , .. } ) =
795
- self . tcx . hir_node ( parent )
793
+ self . tcx . parent_hir_node ( expr . hir_id )
796
794
else {
797
795
return ;
798
796
} ;
@@ -1017,7 +1015,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
1017
1015
) ) = expr. kind
1018
1016
{
1019
1017
let bind = self . tcx . hir_node ( * bind_hir_id) ;
1020
- let parent = self . tcx . hir_node ( self . tcx . hir ( ) . parent_id ( * bind_hir_id) ) ;
1018
+ let parent = self . tcx . parent_hir_node ( * bind_hir_id) ;
1021
1019
if let hir:: Node :: Pat ( hir:: Pat {
1022
1020
kind : hir:: PatKind :: Binding ( _, _hir_id, _, _) , ..
1023
1021
} ) = bind
@@ -1088,7 +1086,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
1088
1086
expr : & hir:: Expr < ' _ > ,
1089
1087
checked_ty : Ty < ' tcx > ,
1090
1088
) {
1091
- let Some ( hir:: Node :: Expr ( parent_expr) ) = self . tcx . hir ( ) . find_parent ( expr. hir_id ) else {
1089
+ let hir:: Node :: Expr ( parent_expr) = self . tcx . parent_hir_node ( expr. hir_id ) else {
1092
1090
return ;
1093
1091
} ;
1094
1092
enum CallableKind {
0 commit comments