@@ -393,7 +393,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
393393
394394 let upvar_hir_id = captured_place. get_root_variable ( ) ;
395395
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)
397397 && let hir:: PatKind :: Binding ( hir:: BindingAnnotation :: NONE , _, upvar_ident, _) =
398398 pat. kind
399399 {
@@ -658,7 +658,6 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
658658 if self . body . local_kind ( local) != LocalKind :: Arg {
659659 return ( false , None ) ;
660660 }
661- let hir_map = self . infcx . tcx . hir ( ) ;
662661 let my_def = self . body . source . def_id ( ) ;
663662 let my_hir = self . infcx . tcx . local_def_id_to_hir_id ( my_def. as_local ( ) . unwrap ( ) ) ;
664663 let Some ( td) =
@@ -668,7 +667,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
668667 } ;
669668 (
670669 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) {
672671 Some ( Node :: Item ( hir:: Item {
673672 kind : hir:: ItemKind :: Trait ( _, _, _, _, items) ,
674673 ..
@@ -679,25 +678,27 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
679678 if !matches ! ( k, hir:: AssocItemKind :: Fn { .. } ) {
680679 continue ;
681680 }
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) {
683682 continue ;
684683 }
685684 f_in_trait_opt = Some ( hi) ;
686685 break ;
687686 }
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 ,
699701 }
700- _ => None ,
701702 } )
702703 }
703704 _ => None ,
@@ -738,12 +739,11 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
738739 }
739740 }
740741
741- let hir_map = self . infcx . tcx . hir ( ) ;
742742 let def_id = self . body . source . def_id ( ) ;
743743 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)
745745 {
746- let body = hir_map . body ( body_id) ;
746+ let body = self . infcx . tcx . hir ( ) . body ( body_id) ;
747747 let mut v = BindingFinder { span : pat_span, hir_id : None } ;
748748 v. visit_body ( body) ;
749749 v. hir_id
@@ -759,7 +759,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
759759 && let Some ( hir:: Node :: Local ( hir:: Local {
760760 pat : hir:: Pat { kind : hir:: PatKind :: Ref ( _, _) , .. } ,
761761 ..
762- } ) ) = hir_map . find ( hir_id)
762+ } ) ) = self . infcx . tcx . opt_hir_node ( hir_id)
763763 && let Ok ( name) =
764764 self . infcx . tcx . sess . source_map ( ) . span_to_snippet ( local_decl. source_info . span )
765765 {
@@ -939,7 +939,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
939939 let closure_id = self . mir_hir_id ( ) ;
940940 let closure_span = self . infcx . tcx . def_span ( self . mir_def_id ( ) ) ;
941941 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) ;
943943 let def_id = hir. enclosing_body_owner ( fn_call_id) ;
944944 let mut look_at_return = true ;
945945 // 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> {
998998 if look_at_return && hir. get_return_block ( closure_id) . is_some ( ) {
999999 // ...otherwise we are probably in the tail expression of the function, point at the
10001000 // 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 ) {
10021002 hir:: Node :: Item ( hir:: Item { ident, kind : hir:: ItemKind :: Fn ( sig, ..) , .. } )
10031003 | hir:: Node :: TraitItem ( hir:: TraitItem {
10041004 ident,
@@ -1196,12 +1196,11 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
11961196 hir:: intravisit:: walk_stmt ( self , s) ;
11971197 }
11981198 }
1199- let hir_map = self . infcx . tcx . hir ( ) ;
12001199 let def_id = self . body . source . def_id ( ) ;
12011200 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)
12031202 {
1204- let body = hir_map . body ( body_id) ;
1203+ let body = self . infcx . tcx . hir ( ) . body ( body_id) ;
12051204 let mut v = BindingFinder { span : err_label_span, hir_id : None } ;
12061205 v. visit_body ( body) ;
12071206 v. hir_id
@@ -1210,7 +1209,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
12101209 } ;
12111210
12121211 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)
12141213 {
12151214 let ( changing, span, sugg) = match local. ty {
12161215 Some ( ty) => ( "changing" , ty. span , message) ,
@@ -1396,7 +1395,7 @@ fn get_mut_span_in_struct_field<'tcx>(
13961395 && let ty:: Adt ( def, _) = ty. kind ( )
13971396 && let field = def. all_fields ( ) . nth ( field. index ( ) ) ?
13981397 // 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 ( ) ?) ?
14001399 // Now we're dealing with the actual struct that we're going to suggest a change to,
14011400 // we can expect a field that is an immutable reference to a type.
14021401 && let hir:: Node :: Field ( field) = node
0 commit comments