33use crate :: build:: expr:: category:: Category ;
44use crate :: build:: ForGuard :: { OutsideGuard , RefWithinGuard } ;
55use crate :: build:: { BlockAnd , BlockAndExtension , Builder } ;
6- use rustc_hir:: def_id:: DefId ;
7- use rustc_hir:: HirId ;
6+ use rustc_hir:: def_id:: { DefId , LocalDefId } ;
87use rustc_middle:: hir:: place:: Projection as HirProjection ;
98use rustc_middle:: hir:: place:: ProjectionKind as HirProjectionKind ;
109use rustc_middle:: middle:: region;
@@ -57,7 +56,7 @@ pub(crate) enum PlaceBase {
5756 /// figure out that it is captured until all the `Field` projections are applied.
5857 Upvar {
5958 /// HirId of the upvar
60- var_hir_id : HirId ,
59+ var_hir_id : LocalVarId ,
6160 /// DefId of the closure
6261 closure_def_id : DefId ,
6362 /// The trait closure implements, `Fn`, `FnMut`, `FnOnce`
@@ -151,12 +150,12 @@ fn is_ancestor_or_same_capture(
151150/// `ty::MinCaptureList` of the root variable `var_hir_id`.
152151fn compute_capture_idx < ' tcx > (
153152 closure_min_captures : & ty:: RootVariableMinCaptureList < ' tcx > ,
154- var_hir_id : HirId ,
153+ var_hir_id : LocalVarId ,
155154 root_var_idx : usize ,
156155) -> usize {
157156 let mut res = 0 ;
158157 for ( var_id, capture_list) in closure_min_captures {
159- if * var_id == var_hir_id {
158+ if * var_id == var_hir_id. 0 {
160159 res += root_var_idx;
161160 break ;
162161 } else {
@@ -176,12 +175,12 @@ fn compute_capture_idx<'tcx>(
176175/// Returns None, when the ancestor is not found.
177176fn find_capture_matching_projections < ' a , ' tcx > (
178177 typeck_results : & ' a ty:: TypeckResults < ' tcx > ,
179- var_hir_id : HirId ,
178+ var_hir_id : LocalVarId ,
180179 closure_def_id : DefId ,
181180 projections : & [ PlaceElem < ' tcx > ] ,
182181) -> Option < ( usize , & ' a ty:: CapturedPlace < ' tcx > ) > {
183182 let closure_min_captures = typeck_results. closure_min_captures . get ( & closure_def_id) ?;
184- let root_variable_min_captures = closure_min_captures. get ( & var_hir_id) ?;
183+ let root_variable_min_captures = closure_min_captures. get ( & var_hir_id. 0 ) ?;
185184
186185 let hir_projections = convert_to_hir_projections_and_truncate_for_capture ( projections) ;
187186
@@ -500,8 +499,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
500499 source_info,
501500 ) ,
502501 ExprKind :: UpvarRef { closure_def_id, var_hir_id } => {
503- let upvar_id = ty:: UpvarId :: new ( var_hir_id, closure_def_id. expect_local ( ) ) ;
504- this. lower_captured_upvar ( block, upvar_id)
502+ this. lower_captured_upvar ( block, closure_def_id. expect_local ( ) , var_hir_id)
505503 }
506504
507505 ExprKind :: VarRef { id } => {
@@ -627,11 +625,11 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
627625 fn lower_captured_upvar (
628626 & mut self ,
629627 block : BasicBlock ,
630- upvar_id : ty:: UpvarId ,
628+ closure_expr_id : LocalDefId ,
629+ var_hir_id : LocalVarId ,
631630 ) -> BlockAnd < PlaceBuilder < ' tcx > > {
632- let closure_ty = self
633- . typeck_results
634- . node_type ( self . tcx . hir ( ) . local_def_id_to_hir_id ( upvar_id. closure_expr_id ) ) ;
631+ let closure_ty =
632+ self . typeck_results . node_type ( self . tcx . hir ( ) . local_def_id_to_hir_id ( closure_expr_id) ) ;
635633
636634 let closure_kind = if let ty:: Closure ( _, closure_substs) = closure_ty. kind ( ) {
637635 self . infcx . closure_kind ( closure_substs) . unwrap ( )
@@ -641,8 +639,8 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
641639 } ;
642640
643641 block. and ( PlaceBuilder :: from ( PlaceBase :: Upvar {
644- var_hir_id : upvar_id . var_path . hir_id ,
645- closure_def_id : upvar_id . closure_expr_id . to_def_id ( ) ,
642+ var_hir_id,
643+ closure_def_id : closure_expr_id. to_def_id ( ) ,
646644 closure_kind,
647645 } ) )
648646 }
0 commit comments