@@ -396,7 +396,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
396
396
397
397
let upvar_hir_id = captured_place. get_root_variable ( ) ;
398
398
399
- if let Some ( Node :: Pat ( pat) ) = self . infcx . tcx . hir ( ) . find ( upvar_hir_id)
399
+ if let Some ( Node :: Pat ( pat) ) = self . infcx . tcx . opt_hir_node ( upvar_hir_id)
400
400
&& let hir:: PatKind :: Binding ( hir:: BindingAnnotation :: NONE , _, upvar_ident, _) =
401
401
pat. kind
402
402
{
@@ -661,7 +661,6 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
661
661
if self . body . local_kind ( local) != LocalKind :: Arg {
662
662
return ( false , None ) ;
663
663
}
664
- let hir_map = self . infcx . tcx . hir ( ) ;
665
664
let my_def = self . body . source . def_id ( ) ;
666
665
let my_hir = self . infcx . tcx . local_def_id_to_hir_id ( my_def. as_local ( ) . unwrap ( ) ) ;
667
666
let Some ( td) =
@@ -671,7 +670,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
671
670
} ;
672
671
(
673
672
true ,
674
- td. as_local ( ) . and_then ( |tld| match hir_map . find_by_def_id ( tld) {
673
+ td. as_local ( ) . and_then ( |tld| match self . infcx . tcx . opt_hir_node_by_def_id ( tld) {
675
674
Some ( Node :: Item ( hir:: Item {
676
675
kind : hir:: ItemKind :: Trait ( _, _, _, _, items) ,
677
676
..
@@ -682,25 +681,27 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
682
681
if !matches ! ( k, hir:: AssocItemKind :: Fn { .. } ) {
683
682
continue ;
684
683
}
685
- if hir_map . name ( hi) != hir_map . name ( my_hir) {
684
+ if self . infcx . tcx . hir ( ) . name ( hi) != self . infcx . tcx . hir ( ) . name ( my_hir) {
686
685
continue ;
687
686
}
688
687
f_in_trait_opt = Some ( hi) ;
689
688
break ;
690
689
}
691
- f_in_trait_opt. and_then ( |f_in_trait| match hir_map. find ( f_in_trait) {
692
- Some ( Node :: TraitItem ( hir:: TraitItem {
693
- kind :
694
- hir:: TraitItemKind :: Fn (
695
- hir:: FnSig { decl : hir:: FnDecl { inputs, .. } , .. } ,
696
- _,
697
- ) ,
698
- ..
699
- } ) ) => {
700
- let hir:: Ty { span, .. } = inputs[ local. index ( ) - 1 ] ;
701
- Some ( span)
690
+ f_in_trait_opt. and_then ( |f_in_trait| {
691
+ match self . infcx . tcx . opt_hir_node ( f_in_trait) {
692
+ Some ( Node :: TraitItem ( hir:: TraitItem {
693
+ kind :
694
+ hir:: TraitItemKind :: Fn (
695
+ hir:: FnSig { decl : hir:: FnDecl { inputs, .. } , .. } ,
696
+ _,
697
+ ) ,
698
+ ..
699
+ } ) ) => {
700
+ let hir:: Ty { span, .. } = inputs[ local. index ( ) - 1 ] ;
701
+ Some ( span)
702
+ }
703
+ _ => None ,
702
704
}
703
- _ => None ,
704
705
} )
705
706
}
706
707
_ => None ,
@@ -741,12 +742,11 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
741
742
}
742
743
}
743
744
744
- let hir_map = self . infcx . tcx . hir ( ) ;
745
745
let def_id = self . body . source . def_id ( ) ;
746
746
let hir_id = if let Some ( local_def_id) = def_id. as_local ( )
747
- && let Some ( body_id) = hir_map . maybe_body_owned_by ( local_def_id)
747
+ && let Some ( body_id) = self . infcx . tcx . hir ( ) . maybe_body_owned_by ( local_def_id)
748
748
{
749
- let body = hir_map . body ( body_id) ;
749
+ let body = self . infcx . tcx . hir ( ) . body ( body_id) ;
750
750
let mut v = BindingFinder { span : pat_span, hir_id : None } ;
751
751
v. visit_body ( body) ;
752
752
v. hir_id
@@ -762,7 +762,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
762
762
&& let Some ( hir:: Node :: Local ( hir:: Local {
763
763
pat : hir:: Pat { kind : hir:: PatKind :: Ref ( _, _) , .. } ,
764
764
..
765
- } ) ) = hir_map . find ( hir_id)
765
+ } ) ) = self . infcx . tcx . opt_hir_node ( hir_id)
766
766
&& let Ok ( name) =
767
767
self . infcx . tcx . sess . source_map ( ) . span_to_snippet ( local_decl. source_info . span )
768
768
{
@@ -942,7 +942,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
942
942
let closure_id = self . mir_hir_id ( ) ;
943
943
let closure_span = self . infcx . tcx . def_span ( self . mir_def_id ( ) ) ;
944
944
let fn_call_id = hir. parent_id ( closure_id) ;
945
- let node = hir . get ( fn_call_id) ;
945
+ let node = self . infcx . tcx . hir_node ( fn_call_id) ;
946
946
let def_id = hir. enclosing_body_owner ( fn_call_id) ;
947
947
let mut look_at_return = true ;
948
948
// If we can detect the expression to be an `fn` call where the closure was an argument,
@@ -1001,7 +1001,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
1001
1001
if look_at_return && hir. get_return_block ( closure_id) . is_some ( ) {
1002
1002
// ...otherwise we are probably in the tail expression of the function, point at the
1003
1003
// return type.
1004
- match hir . get_by_def_id ( hir. get_parent_item ( fn_call_id) . def_id ) {
1004
+ match self . infcx . tcx . hir_node_by_def_id ( hir. get_parent_item ( fn_call_id) . def_id ) {
1005
1005
hir:: Node :: Item ( hir:: Item { ident, kind : hir:: ItemKind :: Fn ( sig, ..) , .. } )
1006
1006
| hir:: Node :: TraitItem ( hir:: TraitItem {
1007
1007
ident,
@@ -1199,12 +1199,11 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
1199
1199
hir:: intravisit:: walk_stmt ( self , s) ;
1200
1200
}
1201
1201
}
1202
- let hir_map = self . infcx . tcx . hir ( ) ;
1203
1202
let def_id = self . body . source . def_id ( ) ;
1204
1203
let hir_id = if let Some ( local_def_id) = def_id. as_local ( )
1205
- && let Some ( body_id) = hir_map . maybe_body_owned_by ( local_def_id)
1204
+ && let Some ( body_id) = self . infcx . tcx . hir ( ) . maybe_body_owned_by ( local_def_id)
1206
1205
{
1207
- let body = hir_map . body ( body_id) ;
1206
+ let body = self . infcx . tcx . hir ( ) . body ( body_id) ;
1208
1207
let mut v = BindingFinder { span : err_label_span, hir_id : None } ;
1209
1208
v. visit_body ( body) ;
1210
1209
v. hir_id
@@ -1213,7 +1212,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
1213
1212
} ;
1214
1213
1215
1214
if let Some ( hir_id) = hir_id
1216
- && let Some ( hir:: Node :: Local ( local) ) = hir_map . find ( hir_id)
1215
+ && let Some ( hir:: Node :: Local ( local) ) = self . infcx . tcx . opt_hir_node ( hir_id)
1217
1216
{
1218
1217
let tables = self . infcx . tcx . typeck ( def_id. as_local ( ) . unwrap ( ) ) ;
1219
1218
if let Some ( clone_trait) = self . infcx . tcx . lang_items ( ) . clone_trait ( )
@@ -1496,7 +1495,7 @@ fn get_mut_span_in_struct_field<'tcx>(
1496
1495
&& let ty:: Adt ( def, _) = ty. kind ( )
1497
1496
&& let field = def. all_fields ( ) . nth ( field. index ( ) ) ?
1498
1497
// Use the HIR types to construct the diagnostic message.
1499
- && let node = tcx. hir ( ) . find_by_def_id ( field. did . as_local ( ) ?) ?
1498
+ && let node = tcx. opt_hir_node_by_def_id ( field. did . as_local ( ) ?) ?
1500
1499
// Now we're dealing with the actual struct that we're going to suggest a change to,
1501
1500
// we can expect a field that is an immutable reference to a type.
1502
1501
&& let hir:: Node :: Field ( field) = node
0 commit comments