@@ -211,7 +211,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
211
211
expr : & hir:: Expr < ' _ > ,
212
212
error : Option < TypeError < ' tcx > > ,
213
213
) {
214
- let parent = self . tcx . hir ( ) . get_parent_node ( expr. hir_id ) ;
214
+ let parent = self . tcx . hir ( ) . parent_id ( expr. hir_id ) ;
215
215
match ( self . tcx . hir ( ) . find ( parent) , error) {
216
216
( Some ( hir:: Node :: Local ( hir:: Local { ty : Some ( ty) , init : Some ( init) , .. } ) ) , _)
217
217
if init. hir_id == expr. hir_id =>
@@ -258,10 +258,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
258
258
hir:: Path { res : hir:: def:: Res :: Local ( hir_id) , .. } ,
259
259
) ) => {
260
260
if let Some ( hir:: Node :: Pat ( pat) ) = self . tcx . hir ( ) . find ( * hir_id) {
261
- let parent = self . tcx . hir ( ) . get_parent_node ( pat. hir_id ) ;
262
261
primary_span = pat. span ;
263
262
secondary_span = pat. span ;
264
- match self . tcx . hir ( ) . find ( parent ) {
263
+ match self . tcx . hir ( ) . find_parent ( pat . hir_id ) {
265
264
Some ( hir:: Node :: Local ( hir:: Local { ty : Some ( ty) , .. } ) ) => {
266
265
primary_span = ty. span ;
267
266
post_message = " type" ;
@@ -326,7 +325,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
326
325
expr : & hir:: Expr < ' _ > ,
327
326
error : Option < TypeError < ' tcx > > ,
328
327
) {
329
- let parent = self . tcx . hir ( ) . get_parent_node ( expr. hir_id ) ;
328
+ let parent = self . tcx . hir ( ) . parent_id ( expr. hir_id ) ;
330
329
let Some ( TypeError :: Sorts ( ExpectedFound { expected, .. } ) ) = error else { return ; } ;
331
330
let Some ( hir:: Node :: Expr ( hir:: Expr {
332
331
kind : hir:: ExprKind :: Assign ( lhs, rhs, _) , ..
@@ -510,7 +509,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
510
509
511
510
// Unroll desugaring, to make sure this works for `for` loops etc.
512
511
loop {
513
- parent = self . tcx . hir ( ) . get_parent_node ( id) ;
512
+ parent = self . tcx . hir ( ) . parent_id ( id) ;
514
513
if let Some ( parent_span) = self . tcx . hir ( ) . opt_span ( parent) {
515
514
if parent_span. find_ancestor_inside ( expr. span ) . is_some ( ) {
516
515
// The parent node is part of the same span, so is the result of the
@@ -790,12 +789,12 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
790
789
return None ;
791
790
} ;
792
791
793
- let local_parent = self . tcx . hir ( ) . get_parent_node ( local_id) ;
792
+ let local_parent = self . tcx . hir ( ) . parent_id ( local_id) ;
794
793
let Some ( Node :: Param ( hir:: Param { hir_id : param_hir_id, .. } ) ) = self . tcx . hir ( ) . find ( local_parent) else {
795
794
return None ;
796
795
} ;
797
796
798
- let param_parent = self . tcx . hir ( ) . get_parent_node ( * param_hir_id) ;
797
+ let param_parent = self . tcx . hir ( ) . parent_id ( * param_hir_id) ;
799
798
let Some ( Node :: Expr ( hir:: Expr {
800
799
hir_id : expr_hir_id,
801
800
kind : hir:: ExprKind :: Closure ( hir:: Closure { fn_decl : closure_fn_decl, .. } ) ,
@@ -804,7 +803,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
804
803
return None ;
805
804
} ;
806
805
807
- let expr_parent = self . tcx . hir ( ) . get_parent_node ( * expr_hir_id) ;
806
+ let expr_parent = self . tcx . hir ( ) . parent_id ( * expr_hir_id) ;
808
807
let hir = self . tcx . hir ( ) . find ( expr_parent) ;
809
808
let closure_params_len = closure_fn_decl. inputs . len ( ) ;
810
809
let (
@@ -857,7 +856,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
857
856
_ => None ,
858
857
} ?;
859
858
860
- match hir. find ( hir . get_parent_node ( expr. hir_id ) ) ? {
859
+ match hir. find_parent ( expr. hir_id ) ? {
861
860
Node :: ExprField ( field) => {
862
861
if field. ident . name == local. name && field. is_shorthand {
863
862
return Some ( local. name ) ;
@@ -883,7 +882,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
883
882
/// Returns whether the given expression is an `else if`.
884
883
pub ( crate ) fn is_else_if_block ( & self , expr : & hir:: Expr < ' _ > ) -> bool {
885
884
if let hir:: ExprKind :: If ( ..) = expr. kind {
886
- let parent_id = self . tcx . hir ( ) . get_parent_node ( expr. hir_id ) ;
885
+ let parent_id = self . tcx . hir ( ) . parent_id ( expr. hir_id ) ;
887
886
if let Some ( Node :: Expr ( hir:: Expr {
888
887
kind : hir:: ExprKind :: If ( _, _, Some ( else_expr) ) ,
889
888
..
@@ -1040,7 +1039,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
1040
1039
if let Some ( hir:: Node :: Expr ( hir:: Expr {
1041
1040
kind : hir:: ExprKind :: Assign ( ..) ,
1042
1041
..
1043
- } ) ) = self . tcx . hir ( ) . find ( self . tcx . hir ( ) . get_parent_node ( expr. hir_id ) )
1042
+ } ) ) = self . tcx . hir ( ) . find_parent ( expr. hir_id )
1044
1043
{
1045
1044
if mutability. is_mut ( ) {
1046
1045
// Suppressing this diagnostic, we'll properly print it in `check_expr_assign`
@@ -1267,9 +1266,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
1267
1266
1268
1267
let mut sugg = vec ! [ ] ;
1269
1268
1270
- if let Some ( hir:: Node :: ExprField ( field) ) =
1271
- self . tcx . hir ( ) . find ( self . tcx . hir ( ) . get_parent_node ( expr. hir_id ) )
1272
- {
1269
+ if let Some ( hir:: Node :: ExprField ( field) ) = self . tcx . hir ( ) . find_parent ( expr. hir_id ) {
1273
1270
// `expr` is a literal field for a struct, only suggest if appropriate
1274
1271
if field. is_shorthand {
1275
1272
// This is a field literal
@@ -1625,7 +1622,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
1625
1622
[ start, end] ,
1626
1623
_,
1627
1624
) = expr. kind else { return ; } ;
1628
- let parent = self . tcx . hir ( ) . get_parent_node ( expr. hir_id ) ;
1625
+ let parent = self . tcx . hir ( ) . parent_id ( expr. hir_id ) ;
1629
1626
if let Some ( hir:: Node :: ExprField ( _) ) = self . tcx . hir ( ) . find ( parent) {
1630
1627
// Ignore `Foo { field: a..Default::default() }`
1631
1628
return ;
0 commit comments