@@ -14,7 +14,7 @@ use rustc_errors::codes::*;
14
14
use rustc_errors:: { Applicability , Diag , MultiSpan , struct_span_code_err} ;
15
15
use rustc_hir as hir;
16
16
use 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} ;
18
18
use rustc_hir:: { CoroutineDesugaring , CoroutineKind , CoroutineSource , LangItem , PatField } ;
19
19
use rustc_middle:: bug;
20
20
use rustc_middle:: hir:: nested_filter:: OnlyBodies ;
@@ -348,13 +348,13 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
348
348
expr : Option < & ' hir hir:: Expr < ' hir > > ,
349
349
pat : Option < & ' hir hir:: Pat < ' hir > > ,
350
350
parent_pat : Option < & ' hir hir:: Pat < ' hir > > ,
351
- hir : rustc_middle :: hir :: map :: Map < ' hir > ,
351
+ tcx : TyCtxt < ' hir > ,
352
352
}
353
353
impl < ' hir > Visitor < ' hir > for ExpressionFinder < ' hir > {
354
354
type NestedFilter = OnlyBodies ;
355
355
356
- fn nested_visit_map ( & mut self ) -> Self :: Map {
357
- self . hir
356
+ fn maybe_tcx ( & mut self ) -> Self :: MaybeTyCtxt {
357
+ self . tcx
358
358
}
359
359
360
360
fn visit_expr ( & mut self , e : & ' hir hir:: Expr < ' hir > ) {
@@ -396,7 +396,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
396
396
expr : None ,
397
397
pat : None ,
398
398
parent_pat : None ,
399
- hir ,
399
+ tcx : self . infcx . tcx ,
400
400
} ;
401
401
finder. visit_expr ( expr) ;
402
402
if let Some ( span) = span
@@ -1082,7 +1082,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
1082
1082
] {
1083
1083
for ( destination, sp) in elements {
1084
1084
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)
1086
1086
&& !matches ! (
1087
1087
sp. desugaring_kind( ) ,
1088
1088
Some ( DesugaringKind :: ForLoop | DesugaringKind :: WhileLoop )
@@ -1437,7 +1437,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
1437
1437
let Some ( hir_generics) = tcx
1438
1438
. typeck_root_def_id ( self . mir_def_id ( ) . to_def_id ( ) )
1439
1439
. as_local ( )
1440
- . and_then ( |def_id| tcx. hir ( ) . get_generics ( def_id) )
1440
+ . and_then ( |def_id| tcx. hir_get_generics ( def_id) )
1441
1441
else {
1442
1442
return ;
1443
1443
} ;
@@ -1889,7 +1889,6 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
1889
1889
1890
1890
fn suggest_copy_for_type_in_cloned_ref ( & self , err : & mut Diag < ' infcx > , place : Place < ' tcx > ) {
1891
1891
let tcx = self . infcx . tcx ;
1892
- let hir = tcx. hir ( ) ;
1893
1892
let Some ( body_id) = tcx. hir_node ( self . mir_hir_id ( ) ) . body_id ( ) else { return } ;
1894
1893
1895
1894
struct FindUselessClone < ' tcx > {
@@ -1917,7 +1916,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
1917
1916
1918
1917
let mut expr_finder = FindUselessClone :: new ( tcx, self . mir_def_id ( ) ) ;
1919
1918
1920
- let body = hir . body ( body_id) . value ;
1919
+ let body = tcx . hir_body ( body_id) . value ;
1921
1920
expr_finder. visit_expr ( body) ;
1922
1921
1923
1922
struct Holds < ' tcx > {
@@ -2106,7 +2105,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
2106
2105
let tcx = self . infcx . tcx ;
2107
2106
let body_id = tcx. hir_node ( self . mir_hir_id ( ) ) . body_id ( ) ?;
2108
2107
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 ) ;
2110
2109
expr_finder. result
2111
2110
}
2112
2111
@@ -2258,7 +2257,6 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
2258
2257
) {
2259
2258
let issue_span = issued_spans. args_or_use ( ) ;
2260
2259
let tcx = self . infcx . tcx ;
2261
- let hir = tcx. hir ( ) ;
2262
2260
2263
2261
let Some ( body_id) = tcx. hir_node ( self . mir_hir_id ( ) ) . body_id ( ) else { return } ;
2264
2262
let typeck_results = tcx. typeck ( self . mir_def_id ( ) ) ;
@@ -2346,7 +2344,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
2346
2344
pat_span : None ,
2347
2345
head : None ,
2348
2346
} ;
2349
- finder. visit_expr ( hir . body ( body_id) . value ) ;
2347
+ finder. visit_expr ( tcx . hir_body ( body_id) . value ) ;
2350
2348
2351
2349
if let Some ( body_expr) = finder. body_expr
2352
2350
&& let Some ( loop_span) = finder. loop_span
@@ -2454,10 +2452,10 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
2454
2452
// Get the body the error happens in
2455
2453
let Some ( body_id) = tcx. hir_node ( self . mir_hir_id ( ) ) . body_id ( ) else { return } ;
2456
2454
2457
- let body_expr = hir . body ( body_id) . value ;
2455
+ let body_expr = tcx . hir_body ( body_id) . value ;
2458
2456
2459
2457
struct ClosureFinder < ' hir > {
2460
- hir : rustc_middle :: hir :: map :: Map < ' hir > ,
2458
+ tcx : TyCtxt < ' hir > ,
2461
2459
borrow_span : Span ,
2462
2460
res : Option < ( & ' hir hir:: Expr < ' hir > , & ' hir hir:: Closure < ' hir > ) > ,
2463
2461
/// The path expression with the `borrow_span` span
@@ -2466,8 +2464,8 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
2466
2464
impl < ' hir > Visitor < ' hir > for ClosureFinder < ' hir > {
2467
2465
type NestedFilter = OnlyBodies ;
2468
2466
2469
- fn nested_visit_map ( & mut self ) -> Self :: Map {
2470
- self . hir
2467
+ fn maybe_tcx ( & mut self ) -> Self :: MaybeTyCtxt {
2468
+ self . tcx
2471
2469
}
2472
2470
2473
2471
fn visit_expr ( & mut self , ex : & ' hir hir:: Expr < ' hir > ) {
@@ -2493,7 +2491,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
2493
2491
2494
2492
// Find the closure that most tightly wraps `capture_kind_span`
2495
2493
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 } ;
2497
2495
finder. visit_expr ( body_expr) ;
2498
2496
let Some ( ( closure_expr, closure) ) = finder. res else { return } ;
2499
2497
@@ -2558,7 +2556,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
2558
2556
}
2559
2557
2560
2558
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 ) ;
2562
2560
2563
2561
spans = finder. spans ;
2564
2562
} else {
@@ -3211,7 +3209,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
3211
3209
if let Some ( scope) = self . body . source_scopes . get ( source_info. scope )
3212
3210
&& let ClearCrossCrate :: Set ( scope_data) = & scope. local_data
3213
3211
&& 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
3215
3213
{
3216
3214
for stmt in block. stmts {
3217
3215
let mut visitor = NestedStatementVisitor {
0 commit comments