@@ -23,9 +23,8 @@ use rustc_hir as hir;
23
23
use rustc_hir:: def_id:: LocalDefId ;
24
24
use rustc_index:: bit_set:: { BitSet , ChunkedBitSet } ;
25
25
use rustc_index:: { IndexSlice , IndexVec } ;
26
- use rustc_infer:: infer:: {
27
- InferCtxt , NllRegionVariableOrigin , RegionVariableOrigin , TyCtxtInferExt ,
28
- } ;
26
+ use rustc_infer:: infer:: TyCtxtInferExt ;
27
+ use rustc_infer:: infer:: { InferCtxt , NllRegionVariableOrigin , RegionVariableOrigin } ;
29
28
use rustc_middle:: mir:: tcx:: PlaceTy ;
30
29
use rustc_middle:: mir:: * ;
31
30
use rustc_middle:: query:: Providers ;
@@ -123,9 +122,8 @@ fn mir_borrowck(tcx: TyCtxt<'_>, def: LocalDefId) -> &BorrowCheckResult<'_> {
123
122
return tcx. arena . alloc ( result) ;
124
123
}
125
124
126
- let infcx = tcx. infer_ctxt ( ) . with_opaque_type_inference ( def) . build ( ) ;
127
125
let promoted: & IndexSlice < _ , _ > = & promoted. borrow ( ) ;
128
- let opt_closure_req = do_mir_borrowck ( & infcx , input_body, promoted, None ) . 0 ;
126
+ let opt_closure_req = do_mir_borrowck ( tcx , input_body, promoted, None ) . 0 ;
129
127
debug ! ( "mir_borrowck done" ) ;
130
128
131
129
tcx. arena . alloc ( opt_closure_req)
@@ -136,18 +134,15 @@ fn mir_borrowck(tcx: TyCtxt<'_>, def: LocalDefId) -> &BorrowCheckResult<'_> {
136
134
/// Use `consumer_options: None` for the default behavior of returning
137
135
/// [`BorrowCheckResult`] only. Otherwise, return [`BodyWithBorrowckFacts`] according
138
136
/// to the given [`ConsumerOptions`].
139
- #[ instrument( skip( infcx , input_body, input_promoted) , fields( id=?input_body. source. def_id( ) ) , level = "debug" ) ]
137
+ #[ instrument( skip( tcx , input_body, input_promoted) , fields( id=?input_body. source. def_id( ) ) , level = "debug" ) ]
140
138
fn do_mir_borrowck < ' tcx > (
141
- infcx : & InferCtxt < ' tcx > ,
139
+ tcx : TyCtxt < ' tcx > ,
142
140
input_body : & Body < ' tcx > ,
143
141
input_promoted : & IndexSlice < Promoted , Body < ' tcx > > ,
144
142
consumer_options : Option < ConsumerOptions > ,
145
143
) -> ( BorrowCheckResult < ' tcx > , Option < Box < BodyWithBorrowckFacts < ' tcx > > > ) {
146
144
let def = input_body. source . def_id ( ) . expect_local ( ) ;
147
- debug ! ( ?def) ;
148
-
149
- let tcx = infcx. tcx ;
150
- let infcx = BorrowckInferCtxt :: new ( infcx) ;
145
+ let infcx = BorrowckInferCtxt :: new ( tcx, def) ;
151
146
let param_env = tcx. param_env ( def) ;
152
147
153
148
let mut local_names = IndexVec :: from_elem ( None , & input_body. local_decls ) ;
@@ -440,13 +435,14 @@ fn do_mir_borrowck<'tcx>(
440
435
( result, body_with_facts)
441
436
}
442
437
443
- pub struct BorrowckInferCtxt < ' cx , ' tcx > {
444
- pub ( crate ) infcx : & ' cx InferCtxt < ' tcx > ,
438
+ pub struct BorrowckInferCtxt < ' tcx > {
439
+ pub ( crate ) infcx : InferCtxt < ' tcx > ,
445
440
pub ( crate ) reg_var_to_origin : RefCell < FxIndexMap < ty:: RegionVid , RegionCtxt > > ,
446
441
}
447
442
448
- impl < ' cx , ' tcx > BorrowckInferCtxt < ' cx , ' tcx > {
449
- pub ( crate ) fn new ( infcx : & ' cx InferCtxt < ' tcx > ) -> Self {
443
+ impl < ' tcx > BorrowckInferCtxt < ' tcx > {
444
+ pub ( crate ) fn new ( tcx : TyCtxt < ' tcx > , def_id : LocalDefId ) -> Self {
445
+ let infcx = tcx. infer_ctxt ( ) . with_opaque_type_inference ( def_id) . build ( ) ;
450
446
BorrowckInferCtxt { infcx, reg_var_to_origin : RefCell :: new ( Default :: default ( ) ) }
451
447
}
452
448
@@ -494,16 +490,16 @@ impl<'cx, 'tcx> BorrowckInferCtxt<'cx, 'tcx> {
494
490
}
495
491
}
496
492
497
- impl < ' cx , ' tcx > Deref for BorrowckInferCtxt < ' cx , ' tcx > {
493
+ impl < ' tcx > Deref for BorrowckInferCtxt < ' tcx > {
498
494
type Target = InferCtxt < ' tcx > ;
499
495
500
- fn deref ( & self ) -> & ' cx Self :: Target {
501
- self . infcx
496
+ fn deref ( & self ) -> & Self :: Target {
497
+ & self . infcx
502
498
}
503
499
}
504
500
505
501
struct MirBorrowckCtxt < ' cx , ' tcx > {
506
- infcx : & ' cx BorrowckInferCtxt < ' cx , ' tcx > ,
502
+ infcx : & ' cx BorrowckInferCtxt < ' tcx > ,
507
503
param_env : ParamEnv < ' tcx > ,
508
504
body : & ' cx Body < ' tcx > ,
509
505
move_data : & ' cx MoveData < ' tcx > ,
0 commit comments