@@ -959,13 +959,16 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
959959 ty:: Generator ( _, substs, _) => ty:: UpvarSubsts :: Generator ( substs) ,
960960 _ => span_bug ! ( self . fn_span, "upvars with non-closure env ty {:?}" , closure_ty) ,
961961 } ;
962+ let def_id = self . def_id . as_local ( ) . unwrap ( ) ;
963+ let capture_syms = tcx. symbols_for_closure_captures ( ( def_id, fn_def_id) ) ;
962964 let capture_tys = upvar_substs. upvar_tys ( ) ;
963- let captures_with_tys =
964- hir_typeck_results. closure_min_captures_flattened ( fn_def_id) . zip ( capture_tys) ;
965+ let captures_with_tys = hir_typeck_results
966+ . closure_min_captures_flattened ( fn_def_id)
967+ . zip ( capture_tys. zip ( capture_syms) ) ;
965968
966969 self . upvar_mutbls = captures_with_tys
967970 . enumerate ( )
968- . map ( |( i, ( captured_place, ty ) ) | {
971+ . map ( |( i, ( captured_place, ( ty , sym ) ) ) | {
969972 let capture = captured_place. info . capture_kind ;
970973 let var_id = match captured_place. place . base {
971974 HirPlaceBase :: Upvar ( upvar_id) => upvar_id. var_path . hir_id ,
@@ -974,8 +977,6 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
974977
975978 let mutability = captured_place. mutability ;
976979
977- let name = captured_place. to_symbol ( tcx) ;
978-
979980 let mut projs = closure_env_projs. clone ( ) ;
980981 projs. push ( ProjectionElem :: Field ( Field :: new ( i) , ty) ) ;
981982 match capture {
@@ -986,7 +987,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
986987 } ;
987988
988989 self . var_debug_info . push ( VarDebugInfo {
989- name,
990+ name : sym ,
990991 source_info : SourceInfo :: outermost ( tcx_hir. span ( var_id) ) ,
991992 value : VarDebugInfoContents :: Place ( Place {
992993 local : ty:: CAPTURE_STRUCT_LOCAL ,
0 commit comments