@@ -18,7 +18,7 @@ use rustc_middle::mir::{
18
18
PlaceRef , ProjectionElem , Rvalue , Statement , StatementKind , Terminator , TerminatorKind ,
19
19
VarBindingForm ,
20
20
} ;
21
- use rustc_middle:: ty:: { self , suggest_constraining_type_params, PredicateKind , Ty } ;
21
+ use rustc_middle:: ty:: { self , suggest_constraining_type_params, PredicateKind , Ty , TyCtxt } ;
22
22
use rustc_middle:: util:: CallKind ;
23
23
use rustc_mir_dataflow:: move_paths:: { InitKind , MoveOutIndex , MovePathIndex } ;
24
24
use rustc_span:: def_id:: LocalDefId ;
@@ -398,7 +398,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
398
398
}
399
399
let typeck = self . infcx . tcx . typeck ( self . mir_def_id ( ) ) ;
400
400
let hir_id = hir. parent_id ( expr. hir_id ) ;
401
- if let Some ( parent) = hir . find ( hir_id) {
401
+ if let Some ( parent) = self . infcx . tcx . opt_hir_node ( hir_id) {
402
402
let ( def_id, args, offset) = if let hir:: Node :: Expr ( parent_expr) = parent
403
403
&& let hir:: ExprKind :: MethodCall ( _, _, args, _) = parent_expr. kind
404
404
&& let Some ( def_id) = typeck. type_dependent_def_id ( parent_expr. hir_id )
@@ -413,7 +413,10 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
413
413
( None , & [ ] [ ..] , 0 )
414
414
} ;
415
415
if let Some ( def_id) = def_id
416
- && let Some ( node) = hir. find ( self . infcx . tcx . local_def_id_to_hir_id ( def_id) )
416
+ && let Some ( node) = self
417
+ . infcx
418
+ . tcx
419
+ . opt_hir_node ( self . infcx . tcx . local_def_id_to_hir_id ( def_id) )
417
420
&& let Some ( fn_sig) = node. fn_sig ( )
418
421
&& let Some ( ident) = node. ident ( )
419
422
&& let Some ( pos) = args. iter ( ) . position ( |arg| arg. hir_id == expr. hir_id )
@@ -1317,7 +1320,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
1317
1320
let tcx = self . infcx . tcx ;
1318
1321
let hir = tcx. hir ( ) ;
1319
1322
1320
- let Some ( body_id) = hir . get ( self . mir_hir_id ( ) ) . body_id ( ) else { return } ;
1323
+ let Some ( body_id) = tcx . hir_node ( self . mir_hir_id ( ) ) . body_id ( ) else { return } ;
1321
1324
let typeck_results = tcx. typeck ( self . mir_def_id ( ) ) ;
1322
1325
1323
1326
struct ExprFinder < ' hir > {
@@ -1509,7 +1512,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
1509
1512
let local_ty = self . body . local_decls [ local] . ty ;
1510
1513
1511
1514
// Get the body the error happens in
1512
- let Some ( body_id) = hir . get ( self . mir_hir_id ( ) ) . body_id ( ) else { return } ;
1515
+ let Some ( body_id) = tcx . hir_node ( self . mir_hir_id ( ) ) . body_id ( ) else { return } ;
1513
1516
1514
1517
let body_expr = hir. body ( body_id) . value ;
1515
1518
@@ -1558,7 +1561,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
1558
1561
// Check that the parent of the closure is a method call,
1559
1562
// with receiver matching with local's type (modulo refs)
1560
1563
let parent = hir. parent_id ( closure_expr. hir_id ) ;
1561
- if let hir:: Node :: Expr ( parent) = hir . get ( parent) {
1564
+ if let hir:: Node :: Expr ( parent) = tcx . hir_node ( parent) {
1562
1565
if let hir:: ExprKind :: MethodCall ( _, recv, ..) = parent. kind {
1563
1566
let recv_ty = typeck_results. expr_ty ( recv) ;
1564
1567
@@ -1635,15 +1638,14 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
1635
1638
issued_spans : & UseSpans < ' tcx > ,
1636
1639
) {
1637
1640
let UseSpans :: ClosureUse { capture_kind_span, .. } = issued_spans else { return } ;
1638
- let hir = self . infcx . tcx . hir ( ) ;
1639
1641
1640
- struct ExpressionFinder < ' hir > {
1642
+ struct ExpressionFinder < ' tcx > {
1641
1643
capture_span : Span ,
1642
1644
closure_change_spans : Vec < Span > ,
1643
1645
closure_arg_span : Option < Span > ,
1644
1646
in_closure : bool ,
1645
1647
suggest_arg : String ,
1646
- hir : rustc_middle :: hir :: map :: Map < ' hir > ,
1648
+ tcx : TyCtxt < ' tcx > ,
1647
1649
closure_local_id : Option < hir:: HirId > ,
1648
1650
closure_call_changes : Vec < ( Span , String ) > ,
1649
1651
}
@@ -1657,7 +1659,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
1657
1659
fn_decl : hir:: FnDecl { inputs, .. } ,
1658
1660
..
1659
1661
} ) = e. kind
1660
- && let Some ( hir:: Node :: Expr ( body) ) = self . hir . find ( body. hir_id )
1662
+ && let Some ( hir:: Node :: Expr ( body) ) = self . tcx . opt_hir_node ( body. hir_id )
1661
1663
{
1662
1664
self . suggest_arg = "this: &Self" . to_string ( ) ;
1663
1665
if inputs. len ( ) > 0 {
@@ -1722,8 +1724,8 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
1722
1724
if let Some ( hir:: Node :: ImplItem ( hir:: ImplItem {
1723
1725
kind : hir:: ImplItemKind :: Fn ( _fn_sig, body_id) ,
1724
1726
..
1725
- } ) ) = hir . find ( self . mir_hir_id ( ) )
1726
- && let Some ( hir:: Node :: Expr ( expr) ) = hir . find ( body_id. hir_id )
1727
+ } ) ) = self . infcx . tcx . opt_hir_node ( self . mir_hir_id ( ) )
1728
+ && let Some ( hir:: Node :: Expr ( expr) ) = self . infcx . tcx . opt_hir_node ( body_id. hir_id )
1727
1729
{
1728
1730
let mut finder = ExpressionFinder {
1729
1731
capture_span : * capture_kind_span,
@@ -1733,7 +1735,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
1733
1735
suggest_arg : String :: new ( ) ,
1734
1736
closure_local_id : None ,
1735
1737
closure_call_changes : vec ! [ ] ,
1736
- hir ,
1738
+ tcx : self . infcx . tcx ,
1737
1739
} ;
1738
1740
finder. visit_expr ( expr) ;
1739
1741
@@ -2294,7 +2296,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
2294
2296
let proper_span = proper_span. source_callsite ( ) ;
2295
2297
if let Some ( scope) = self . body . source_scopes . get ( source_info. scope )
2296
2298
&& let ClearCrossCrate :: Set ( scope_data) = & scope. local_data
2297
- && let Some ( node) = self . infcx . tcx . hir ( ) . find ( scope_data. lint_root )
2299
+ && let Some ( node) = self . infcx . tcx . opt_hir_node ( scope_data. lint_root )
2298
2300
&& let Some ( id) = node. body_id ( )
2299
2301
&& let hir:: ExprKind :: Block ( block, _) = self . infcx . tcx . hir ( ) . body ( id) . value . kind
2300
2302
{
0 commit comments