@@ -959,13 +959,16 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
959
959
ty:: Generator ( _, substs, _) => ty:: UpvarSubsts :: Generator ( substs) ,
960
960
_ => span_bug ! ( self . fn_span, "upvars with non-closure env ty {:?}" , closure_ty) ,
961
961
} ;
962
+ let def_id = self . def_id . as_local ( ) . unwrap ( ) ;
963
+ let capture_syms = tcx. symbols_for_closure_captures ( ( def_id, fn_def_id) ) ;
962
964
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) ) ;
965
968
966
969
self . upvar_mutbls = captures_with_tys
967
970
. enumerate ( )
968
- . map ( |( i, ( captured_place, ty ) ) | {
971
+ . map ( |( i, ( captured_place, ( ty , sym ) ) ) | {
969
972
let capture = captured_place. info . capture_kind ;
970
973
let var_id = match captured_place. place . base {
971
974
HirPlaceBase :: Upvar ( upvar_id) => upvar_id. var_path . hir_id ,
@@ -974,8 +977,6 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
974
977
975
978
let mutability = captured_place. mutability ;
976
979
977
- let name = captured_place. to_symbol ( tcx) ;
978
-
979
980
let mut projs = closure_env_projs. clone ( ) ;
980
981
projs. push ( ProjectionElem :: Field ( Field :: new ( i) , ty) ) ;
981
982
match capture {
@@ -986,7 +987,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
986
987
} ;
987
988
988
989
self . var_debug_info . push ( VarDebugInfo {
989
- name,
990
+ name : sym ,
990
991
source_info : SourceInfo :: outermost ( tcx_hir. span ( var_id) ) ,
991
992
value : VarDebugInfoContents :: Place ( Place {
992
993
local : ty:: CAPTURE_STRUCT_LOCAL ,
0 commit comments