@@ -430,7 +430,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
430
430
expr : & hir:: Expr < ' _ > ,
431
431
error : Option < TypeError < ' tcx > > ,
432
432
) {
433
- let parent = self . tcx . hir ( ) . get_parent_node ( expr. hir_id ) ;
433
+ let parent = self . tcx . hir ( ) . parent_id ( expr. hir_id ) ;
434
434
match ( self . tcx . hir ( ) . find ( parent) , error) {
435
435
( Some ( hir:: Node :: Local ( hir:: Local { ty : Some ( ty) , init : Some ( init) , .. } ) ) , _)
436
436
if init. hir_id == expr. hir_id =>
@@ -477,10 +477,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
477
477
hir:: Path { res : hir:: def:: Res :: Local ( hir_id) , .. } ,
478
478
) ) => {
479
479
if let Some ( hir:: Node :: Pat ( pat) ) = self . tcx . hir ( ) . find ( * hir_id) {
480
- let parent = self . tcx . hir ( ) . get_parent_node ( pat. hir_id ) ;
481
480
primary_span = pat. span ;
482
481
secondary_span = pat. span ;
483
- match self . tcx . hir ( ) . find ( parent ) {
482
+ match self . tcx . hir ( ) . find_parent ( pat . hir_id ) {
484
483
Some ( hir:: Node :: Local ( hir:: Local { ty : Some ( ty) , .. } ) ) => {
485
484
primary_span = ty. span ;
486
485
post_message = " type" ;
@@ -545,7 +544,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
545
544
expr : & hir:: Expr < ' _ > ,
546
545
error : Option < TypeError < ' tcx > > ,
547
546
) {
548
- let parent = self . tcx . hir ( ) . get_parent_node ( expr. hir_id ) ;
547
+ let parent = self . tcx . hir ( ) . parent_id ( expr. hir_id ) ;
549
548
let Some ( TypeError :: Sorts ( ExpectedFound { expected, .. } ) ) = error else { return ; } ;
550
549
let Some ( hir:: Node :: Expr ( hir:: Expr {
551
550
kind : hir:: ExprKind :: Assign ( lhs, rhs, _) , ..
@@ -729,7 +728,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
729
728
730
729
// Unroll desugaring, to make sure this works for `for` loops etc.
731
730
loop {
732
- parent = self . tcx . hir ( ) . get_parent_node ( id) ;
731
+ parent = self . tcx . hir ( ) . parent_id ( id) ;
733
732
if let Some ( parent_span) = self . tcx . hir ( ) . opt_span ( parent) {
734
733
if parent_span. find_ancestor_inside ( expr. span ) . is_some ( ) {
735
734
// The parent node is part of the same span, so is the result of the
@@ -1009,12 +1008,12 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
1009
1008
return None ;
1010
1009
} ;
1011
1010
1012
- let local_parent = self . tcx . hir ( ) . get_parent_node ( local_id) ;
1011
+ let local_parent = self . tcx . hir ( ) . parent_id ( local_id) ;
1013
1012
let Some ( Node :: Param ( hir:: Param { hir_id : param_hir_id, .. } ) ) = self . tcx . hir ( ) . find ( local_parent) else {
1014
1013
return None ;
1015
1014
} ;
1016
1015
1017
- let param_parent = self . tcx . hir ( ) . get_parent_node ( * param_hir_id) ;
1016
+ let param_parent = self . tcx . hir ( ) . parent_id ( * param_hir_id) ;
1018
1017
let Some ( Node :: Expr ( hir:: Expr {
1019
1018
hir_id : expr_hir_id,
1020
1019
kind : hir:: ExprKind :: Closure ( hir:: Closure { fn_decl : closure_fn_decl, .. } ) ,
@@ -1023,7 +1022,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
1023
1022
return None ;
1024
1023
} ;
1025
1024
1026
- let expr_parent = self . tcx . hir ( ) . get_parent_node ( * expr_hir_id) ;
1025
+ let expr_parent = self . tcx . hir ( ) . parent_id ( * expr_hir_id) ;
1027
1026
let hir = self . tcx . hir ( ) . find ( expr_parent) ;
1028
1027
let closure_params_len = closure_fn_decl. inputs . len ( ) ;
1029
1028
let (
@@ -1076,7 +1075,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
1076
1075
_ => None ,
1077
1076
} ?;
1078
1077
1079
- match hir. find ( hir . get_parent_node ( expr. hir_id ) ) ? {
1078
+ match hir. find_parent ( expr. hir_id ) ? {
1080
1079
Node :: ExprField ( field) => {
1081
1080
if field. ident . name == local. name && field. is_shorthand {
1082
1081
return Some ( local. name ) ;
@@ -1102,7 +1101,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
1102
1101
/// Returns whether the given expression is an `else if`.
1103
1102
pub ( crate ) fn is_else_if_block ( & self , expr : & hir:: Expr < ' _ > ) -> bool {
1104
1103
if let hir:: ExprKind :: If ( ..) = expr. kind {
1105
- let parent_id = self . tcx . hir ( ) . get_parent_node ( expr. hir_id ) ;
1104
+ let parent_id = self . tcx . hir ( ) . parent_id ( expr. hir_id ) ;
1106
1105
if let Some ( Node :: Expr ( hir:: Expr {
1107
1106
kind : hir:: ExprKind :: If ( _, _, Some ( else_expr) ) ,
1108
1107
..
@@ -1259,7 +1258,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
1259
1258
if let Some ( hir:: Node :: Expr ( hir:: Expr {
1260
1259
kind : hir:: ExprKind :: Assign ( ..) ,
1261
1260
..
1262
- } ) ) = self . tcx . hir ( ) . find ( self . tcx . hir ( ) . get_parent_node ( expr. hir_id ) )
1261
+ } ) ) = self . tcx . hir ( ) . find_parent ( expr. hir_id )
1263
1262
{
1264
1263
if mutability. is_mut ( ) {
1265
1264
// Suppressing this diagnostic, we'll properly print it in `check_expr_assign`
@@ -1486,9 +1485,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
1486
1485
1487
1486
let mut sugg = vec ! [ ] ;
1488
1487
1489
- if let Some ( hir:: Node :: ExprField ( field) ) =
1490
- self . tcx . hir ( ) . find ( self . tcx . hir ( ) . get_parent_node ( expr. hir_id ) )
1491
- {
1488
+ if let Some ( hir:: Node :: ExprField ( field) ) = self . tcx . hir ( ) . find_parent ( expr. hir_id ) {
1492
1489
// `expr` is a literal field for a struct, only suggest if appropriate
1493
1490
if field. is_shorthand {
1494
1491
// This is a field literal
@@ -1844,7 +1841,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
1844
1841
[ start, end] ,
1845
1842
_,
1846
1843
) = expr. kind else { return ; } ;
1847
- let parent = self . tcx . hir ( ) . get_parent_node ( expr. hir_id ) ;
1844
+ let parent = self . tcx . hir ( ) . parent_id ( expr. hir_id ) ;
1848
1845
if let Some ( hir:: Node :: ExprField ( _) ) = self . tcx . hir ( ) . find ( parent) {
1849
1846
// Ignore `Foo { field: a..Default::default() }`
1850
1847
return ;
0 commit comments