@@ -396,7 +396,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
396396
397397 let upvar_hir_id = captured_place. get_root_variable ( ) ;
398398
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)
400400 && let hir:: PatKind :: Binding ( hir:: BindingAnnotation :: NONE , _, upvar_ident, _) =
401401 pat. kind
402402 {
@@ -661,7 +661,6 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
661661 if self . body . local_kind ( local) != LocalKind :: Arg {
662662 return ( false , None ) ;
663663 }
664- let hir_map = self . infcx . tcx . hir ( ) ;
665664 let my_def = self . body . source . def_id ( ) ;
666665 let my_hir = self . infcx . tcx . local_def_id_to_hir_id ( my_def. as_local ( ) . unwrap ( ) ) ;
667666 let Some ( td) =
@@ -671,7 +670,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
671670 } ;
672671 (
673672 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) {
675674 Some ( Node :: Item ( hir:: Item {
676675 kind : hir:: ItemKind :: Trait ( _, _, _, _, items) ,
677676 ..
@@ -682,25 +681,27 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
682681 if !matches ! ( k, hir:: AssocItemKind :: Fn { .. } ) {
683682 continue ;
684683 }
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) {
686685 continue ;
687686 }
688687 f_in_trait_opt = Some ( hi) ;
689688 break ;
690689 }
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 ,
702704 }
703- _ => None ,
704705 } )
705706 }
706707 _ => None ,
@@ -741,12 +742,11 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
741742 }
742743 }
743744
744- let hir_map = self . infcx . tcx . hir ( ) ;
745745 let def_id = self . body . source . def_id ( ) ;
746746 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)
748748 {
749- let body = hir_map . body ( body_id) ;
749+ let body = self . infcx . tcx . hir ( ) . body ( body_id) ;
750750 let mut v = BindingFinder { span : pat_span, hir_id : None } ;
751751 v. visit_body ( body) ;
752752 v. hir_id
@@ -762,7 +762,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
762762 && let Some ( hir:: Node :: Local ( hir:: Local {
763763 pat : hir:: Pat { kind : hir:: PatKind :: Ref ( _, _) , .. } ,
764764 ..
765- } ) ) = hir_map . find ( hir_id)
765+ } ) ) = self . infcx . tcx . opt_hir_node ( hir_id)
766766 && let Ok ( name) =
767767 self . infcx . tcx . sess . source_map ( ) . span_to_snippet ( local_decl. source_info . span )
768768 {
@@ -942,7 +942,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
942942 let closure_id = self . mir_hir_id ( ) ;
943943 let closure_span = self . infcx . tcx . def_span ( self . mir_def_id ( ) ) ;
944944 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) ;
946946 let def_id = hir. enclosing_body_owner ( fn_call_id) ;
947947 let mut look_at_return = true ;
948948 // 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> {
10011001 if look_at_return && hir. get_return_block ( closure_id) . is_some ( ) {
10021002 // ...otherwise we are probably in the tail expression of the function, point at the
10031003 // 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 ) {
10051005 hir:: Node :: Item ( hir:: Item { ident, kind : hir:: ItemKind :: Fn ( sig, ..) , .. } )
10061006 | hir:: Node :: TraitItem ( hir:: TraitItem {
10071007 ident,
@@ -1199,12 +1199,11 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
11991199 hir:: intravisit:: walk_stmt ( self , s) ;
12001200 }
12011201 }
1202- let hir_map = self . infcx . tcx . hir ( ) ;
12031202 let def_id = self . body . source . def_id ( ) ;
12041203 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)
12061205 {
1207- let body = hir_map . body ( body_id) ;
1206+ let body = self . infcx . tcx . hir ( ) . body ( body_id) ;
12081207 let mut v = BindingFinder { span : err_label_span, hir_id : None } ;
12091208 v. visit_body ( body) ;
12101209 v. hir_id
@@ -1213,7 +1212,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
12131212 } ;
12141213
12151214 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)
12171216 {
12181217 let tables = self . infcx . tcx . typeck ( def_id. as_local ( ) . unwrap ( ) ) ;
12191218 if let Some ( clone_trait) = self . infcx . tcx . lang_items ( ) . clone_trait ( )
@@ -1496,7 +1495,7 @@ fn get_mut_span_in_struct_field<'tcx>(
14961495 && let ty:: Adt ( def, _) = ty. kind ( )
14971496 && let field = def. all_fields ( ) . nth ( field. index ( ) ) ?
14981497 // 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 ( ) ?) ?
15001499 // Now we're dealing with the actual struct that we're going to suggest a change to,
15011500 // we can expect a field that is an immutable reference to a type.
15021501 && let hir:: Node :: Field ( field) = node
0 commit comments