@@ -14,7 +14,7 @@ use rustc_errors::codes::*;
1414use rustc_errors:: { Applicability , Diag , MultiSpan , struct_span_code_err} ;
1515use rustc_hir as hir;
1616use rustc_hir:: def:: { DefKind , Res } ;
17- use rustc_hir:: intravisit:: { Map , Visitor , walk_block, walk_expr} ;
17+ use rustc_hir:: intravisit:: { Visitor , walk_block, walk_expr} ;
1818use rustc_hir:: { CoroutineDesugaring , CoroutineKind , CoroutineSource , LangItem , PatField } ;
1919use rustc_middle:: bug;
2020use rustc_middle:: hir:: nested_filter:: OnlyBodies ;
@@ -348,13 +348,13 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
348348 expr : Option < & ' hir hir:: Expr < ' hir > > ,
349349 pat : Option < & ' hir hir:: Pat < ' hir > > ,
350350 parent_pat : Option < & ' hir hir:: Pat < ' hir > > ,
351- hir : rustc_middle :: hir :: map :: Map < ' hir > ,
351+ tcx : TyCtxt < ' hir > ,
352352 }
353353 impl < ' hir > Visitor < ' hir > for ExpressionFinder < ' hir > {
354354 type NestedFilter = OnlyBodies ;
355355
356- fn nested_visit_map ( & mut self ) -> Self :: Map {
357- self . hir
356+ fn maybe_tcx ( & mut self ) -> Self :: MaybeTyCtxt {
357+ self . tcx
358358 }
359359
360360 fn visit_expr ( & mut self , e : & ' hir hir:: Expr < ' hir > ) {
@@ -396,7 +396,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
396396 expr : None ,
397397 pat : None ,
398398 parent_pat : None ,
399- hir ,
399+ tcx : self . infcx . tcx ,
400400 } ;
401401 finder. visit_expr ( expr) ;
402402 if let Some ( span) = span
@@ -1082,7 +1082,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
10821082 ] {
10831083 for ( destination, sp) in elements {
10841084 if let Ok ( hir_id) = destination. target_id
1085- && let hir:: Node :: Expr ( expr) = tcx. hir ( ) . hir_node ( hir_id)
1085+ && let hir:: Node :: Expr ( expr) = tcx. hir_node ( hir_id)
10861086 && !matches ! (
10871087 sp. desugaring_kind( ) ,
10881088 Some ( DesugaringKind :: ForLoop | DesugaringKind :: WhileLoop )
@@ -1437,7 +1437,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
14371437 let Some ( hir_generics) = tcx
14381438 . typeck_root_def_id ( self . mir_def_id ( ) . to_def_id ( ) )
14391439 . as_local ( )
1440- . and_then ( |def_id| tcx. hir ( ) . get_generics ( def_id) )
1440+ . and_then ( |def_id| tcx. hir_get_generics ( def_id) )
14411441 else {
14421442 return ;
14431443 } ;
@@ -1889,7 +1889,6 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
18891889
18901890 fn suggest_copy_for_type_in_cloned_ref ( & self , err : & mut Diag < ' infcx > , place : Place < ' tcx > ) {
18911891 let tcx = self . infcx . tcx ;
1892- let hir = tcx. hir ( ) ;
18931892 let Some ( body_id) = tcx. hir_node ( self . mir_hir_id ( ) ) . body_id ( ) else { return } ;
18941893
18951894 struct FindUselessClone < ' tcx > {
@@ -1917,7 +1916,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
19171916
19181917 let mut expr_finder = FindUselessClone :: new ( tcx, self . mir_def_id ( ) ) ;
19191918
1920- let body = hir . body ( body_id) . value ;
1919+ let body = tcx . hir_body ( body_id) . value ;
19211920 expr_finder. visit_expr ( body) ;
19221921
19231922 struct Holds < ' tcx > {
@@ -2106,7 +2105,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
21062105 let tcx = self . infcx . tcx ;
21072106 let body_id = tcx. hir_node ( self . mir_hir_id ( ) ) . body_id ( ) ?;
21082107 let mut expr_finder = FindExprBySpan :: new ( span, tcx) ;
2109- expr_finder. visit_expr ( tcx. hir ( ) . body ( body_id) . value ) ;
2108+ expr_finder. visit_expr ( tcx. hir_body ( body_id) . value ) ;
21102109 expr_finder. result
21112110 }
21122111
@@ -2258,7 +2257,6 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
22582257 ) {
22592258 let issue_span = issued_spans. args_or_use ( ) ;
22602259 let tcx = self . infcx . tcx ;
2261- let hir = tcx. hir ( ) ;
22622260
22632261 let Some ( body_id) = tcx. hir_node ( self . mir_hir_id ( ) ) . body_id ( ) else { return } ;
22642262 let typeck_results = tcx. typeck ( self . mir_def_id ( ) ) ;
@@ -2346,7 +2344,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
23462344 pat_span : None ,
23472345 head : None ,
23482346 } ;
2349- finder. visit_expr ( hir . body ( body_id) . value ) ;
2347+ finder. visit_expr ( tcx . hir_body ( body_id) . value ) ;
23502348
23512349 if let Some ( body_expr) = finder. body_expr
23522350 && let Some ( loop_span) = finder. loop_span
@@ -2454,10 +2452,10 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
24542452 // Get the body the error happens in
24552453 let Some ( body_id) = tcx. hir_node ( self . mir_hir_id ( ) ) . body_id ( ) else { return } ;
24562454
2457- let body_expr = hir . body ( body_id) . value ;
2455+ let body_expr = tcx . hir_body ( body_id) . value ;
24582456
24592457 struct ClosureFinder < ' hir > {
2460- hir : rustc_middle :: hir :: map :: Map < ' hir > ,
2458+ tcx : TyCtxt < ' hir > ,
24612459 borrow_span : Span ,
24622460 res : Option < ( & ' hir hir:: Expr < ' hir > , & ' hir hir:: Closure < ' hir > ) > ,
24632461 /// The path expression with the `borrow_span` span
@@ -2466,8 +2464,8 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
24662464 impl < ' hir > Visitor < ' hir > for ClosureFinder < ' hir > {
24672465 type NestedFilter = OnlyBodies ;
24682466
2469- fn nested_visit_map ( & mut self ) -> Self :: Map {
2470- self . hir
2467+ fn maybe_tcx ( & mut self ) -> Self :: MaybeTyCtxt {
2468+ self . tcx
24712469 }
24722470
24732471 fn visit_expr ( & mut self , ex : & ' hir hir:: Expr < ' hir > ) {
@@ -2493,7 +2491,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
24932491
24942492 // Find the closure that most tightly wraps `capture_kind_span`
24952493 let mut finder =
2496- ClosureFinder { hir , borrow_span : capture_kind_span, res : None , error_path : None } ;
2494+ ClosureFinder { tcx , borrow_span : capture_kind_span, res : None , error_path : None } ;
24972495 finder. visit_expr ( body_expr) ;
24982496 let Some ( ( closure_expr, closure) ) = finder. res else { return } ;
24992497
@@ -2558,7 +2556,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
25582556 }
25592557
25602558 let mut finder = VariableUseFinder { local_id, spans : Vec :: new ( ) } ;
2561- finder. visit_expr ( hir . body ( closure. body ) . value ) ;
2559+ finder. visit_expr ( tcx . hir_body ( closure. body ) . value ) ;
25622560
25632561 spans = finder. spans ;
25642562 } else {
@@ -3211,7 +3209,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
32113209 if let Some ( scope) = self . body . source_scopes . get ( source_info. scope )
32123210 && let ClearCrossCrate :: Set ( scope_data) = & scope. local_data
32133211 && let Some ( id) = self . infcx . tcx . hir_node ( scope_data. lint_root ) . body_id ( )
3214- && let hir:: ExprKind :: Block ( block, _) = self . infcx . tcx . hir ( ) . body ( id) . value . kind
3212+ && let hir:: ExprKind :: Block ( block, _) = self . infcx . tcx . hir_body ( id) . value . kind
32153213 {
32163214 for stmt in block. stmts {
32173215 let mut visitor = NestedStatementVisitor {
0 commit comments