@@ -393,7 +393,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
393
393
394
394
let upvar_hir_id = captured_place. get_root_variable ( ) ;
395
395
396
- if let Some ( Node :: Pat ( pat) ) = self . infcx . tcx . hir ( ) . find ( upvar_hir_id)
396
+ if let Some ( Node :: Pat ( pat) ) = self . infcx . tcx . opt_hir_node ( upvar_hir_id)
397
397
&& let hir:: PatKind :: Binding ( hir:: BindingAnnotation :: NONE , _, upvar_ident, _) =
398
398
pat. kind
399
399
{
@@ -658,7 +658,6 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
658
658
if self . body . local_kind ( local) != LocalKind :: Arg {
659
659
return ( false , None ) ;
660
660
}
661
- let hir_map = self . infcx . tcx . hir ( ) ;
662
661
let my_def = self . body . source . def_id ( ) ;
663
662
let my_hir = self . infcx . tcx . local_def_id_to_hir_id ( my_def. as_local ( ) . unwrap ( ) ) ;
664
663
let Some ( td) =
@@ -668,7 +667,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
668
667
} ;
669
668
(
670
669
true ,
671
- td. as_local ( ) . and_then ( |tld| match hir_map . find_by_def_id ( tld) {
670
+ td. as_local ( ) . and_then ( |tld| match self . infcx . tcx . opt_hir_node_by_def_id ( tld) {
672
671
Some ( Node :: Item ( hir:: Item {
673
672
kind : hir:: ItemKind :: Trait ( _, _, _, _, items) ,
674
673
..
@@ -679,25 +678,27 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
679
678
if !matches ! ( k, hir:: AssocItemKind :: Fn { .. } ) {
680
679
continue ;
681
680
}
682
- if hir_map . name ( hi) != hir_map . name ( my_hir) {
681
+ if self . infcx . tcx . hir ( ) . name ( hi) != self . infcx . tcx . hir ( ) . name ( my_hir) {
683
682
continue ;
684
683
}
685
684
f_in_trait_opt = Some ( hi) ;
686
685
break ;
687
686
}
688
- f_in_trait_opt. and_then ( |f_in_trait| match hir_map. find ( f_in_trait) {
689
- Some ( Node :: TraitItem ( hir:: TraitItem {
690
- kind :
691
- hir:: TraitItemKind :: Fn (
692
- hir:: FnSig { decl : hir:: FnDecl { inputs, .. } , .. } ,
693
- _,
694
- ) ,
695
- ..
696
- } ) ) => {
697
- let hir:: Ty { span, .. } = inputs[ local. index ( ) - 1 ] ;
698
- Some ( span)
687
+ f_in_trait_opt. and_then ( |f_in_trait| {
688
+ match self . infcx . tcx . opt_hir_node ( f_in_trait) {
689
+ Some ( Node :: TraitItem ( hir:: TraitItem {
690
+ kind :
691
+ hir:: TraitItemKind :: Fn (
692
+ hir:: FnSig { decl : hir:: FnDecl { inputs, .. } , .. } ,
693
+ _,
694
+ ) ,
695
+ ..
696
+ } ) ) => {
697
+ let hir:: Ty { span, .. } = inputs[ local. index ( ) - 1 ] ;
698
+ Some ( span)
699
+ }
700
+ _ => None ,
699
701
}
700
- _ => None ,
701
702
} )
702
703
}
703
704
_ => None ,
@@ -738,12 +739,11 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
738
739
}
739
740
}
740
741
741
- let hir_map = self . infcx . tcx . hir ( ) ;
742
742
let def_id = self . body . source . def_id ( ) ;
743
743
let hir_id = if let Some ( local_def_id) = def_id. as_local ( )
744
- && let Some ( body_id) = hir_map . maybe_body_owned_by ( local_def_id)
744
+ && let Some ( body_id) = self . infcx . tcx . hir ( ) . maybe_body_owned_by ( local_def_id)
745
745
{
746
- let body = hir_map . body ( body_id) ;
746
+ let body = self . infcx . tcx . hir ( ) . body ( body_id) ;
747
747
let mut v = BindingFinder { span : pat_span, hir_id : None } ;
748
748
v. visit_body ( body) ;
749
749
v. hir_id
@@ -759,7 +759,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
759
759
&& let Some ( hir:: Node :: Local ( hir:: Local {
760
760
pat : hir:: Pat { kind : hir:: PatKind :: Ref ( _, _) , .. } ,
761
761
..
762
- } ) ) = hir_map . find ( hir_id)
762
+ } ) ) = self . infcx . tcx . opt_hir_node ( hir_id)
763
763
&& let Ok ( name) =
764
764
self . infcx . tcx . sess . source_map ( ) . span_to_snippet ( local_decl. source_info . span )
765
765
{
@@ -939,7 +939,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
939
939
let closure_id = self . mir_hir_id ( ) ;
940
940
let closure_span = self . infcx . tcx . def_span ( self . mir_def_id ( ) ) ;
941
941
let fn_call_id = hir. parent_id ( closure_id) ;
942
- let node = hir . get ( fn_call_id) ;
942
+ let node = self . infcx . tcx . hir_node ( fn_call_id) ;
943
943
let def_id = hir. enclosing_body_owner ( fn_call_id) ;
944
944
let mut look_at_return = true ;
945
945
// If we can detect the expression to be an `fn` call where the closure was an argument,
@@ -998,7 +998,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
998
998
if look_at_return && hir. get_return_block ( closure_id) . is_some ( ) {
999
999
// ...otherwise we are probably in the tail expression of the function, point at the
1000
1000
// return type.
1001
- match hir . get_by_def_id ( hir. get_parent_item ( fn_call_id) . def_id ) {
1001
+ match self . infcx . tcx . hir_node_by_def_id ( hir. get_parent_item ( fn_call_id) . def_id ) {
1002
1002
hir:: Node :: Item ( hir:: Item { ident, kind : hir:: ItemKind :: Fn ( sig, ..) , .. } )
1003
1003
| hir:: Node :: TraitItem ( hir:: TraitItem {
1004
1004
ident,
@@ -1196,12 +1196,11 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
1196
1196
hir:: intravisit:: walk_stmt ( self , s) ;
1197
1197
}
1198
1198
}
1199
- let hir_map = self . infcx . tcx . hir ( ) ;
1200
1199
let def_id = self . body . source . def_id ( ) ;
1201
1200
let hir_id = if let Some ( local_def_id) = def_id. as_local ( )
1202
- && let Some ( body_id) = hir_map . maybe_body_owned_by ( local_def_id)
1201
+ && let Some ( body_id) = self . infcx . tcx . hir ( ) . maybe_body_owned_by ( local_def_id)
1203
1202
{
1204
- let body = hir_map . body ( body_id) ;
1203
+ let body = self . infcx . tcx . hir ( ) . body ( body_id) ;
1205
1204
let mut v = BindingFinder { span : err_label_span, hir_id : None } ;
1206
1205
v. visit_body ( body) ;
1207
1206
v. hir_id
@@ -1210,7 +1209,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
1210
1209
} ;
1211
1210
1212
1211
if let Some ( hir_id) = hir_id
1213
- && let Some ( hir:: Node :: Local ( local) ) = hir_map . find ( hir_id)
1212
+ && let Some ( hir:: Node :: Local ( local) ) = self . infcx . tcx . opt_hir_node ( hir_id)
1214
1213
{
1215
1214
let ( changing, span, sugg) = match local. ty {
1216
1215
Some ( ty) => ( "changing" , ty. span , message) ,
@@ -1396,7 +1395,7 @@ fn get_mut_span_in_struct_field<'tcx>(
1396
1395
&& let ty:: Adt ( def, _) = ty. kind ( )
1397
1396
&& let field = def. all_fields ( ) . nth ( field. index ( ) ) ?
1398
1397
// Use the HIR types to construct the diagnostic message.
1399
- && let node = tcx. hir ( ) . find_by_def_id ( field. did . as_local ( ) ?) ?
1398
+ && let node = tcx. opt_hir_node_by_def_id ( field. did . as_local ( ) ?) ?
1400
1399
// Now we're dealing with the actual struct that we're going to suggest a change to,
1401
1400
// we can expect a field that is an immutable reference to a type.
1402
1401
&& let hir:: Node :: Field ( field) = node
0 commit comments