@@ -27,9 +27,7 @@ use rustc_codegen_ssa::traits::*;
2727use rustc_fs_util:: path_to_c_string;
2828use rustc_hir:: def:: CtorKind ;
2929use rustc_hir:: def_id:: { DefId , LOCAL_CRATE } ;
30- use rustc_index:: vec:: { Idx , IndexVec } ;
3130use rustc_middle:: bug;
32- use rustc_middle:: mir:: { self , GeneratorLayout } ;
3331use rustc_middle:: ty:: layout:: { LayoutOf , TyAndLayout } ;
3432use rustc_middle:: ty:: subst:: GenericArgKind ;
3533use rustc_middle:: ty:: {
@@ -1026,33 +1024,6 @@ fn build_struct_type_di_node<'ll, 'tcx>(
10261024// Tuples
10271025//=-----------------------------------------------------------------------------
10281026
1029- /// Returns names of captured upvars for closures and generators.
1030- ///
1031- /// Here are some examples:
1032- /// - `name__field1__field2` when the upvar is captured by value.
1033- /// - `_ref__name__field` when the upvar is captured by reference.
1034- ///
1035- /// For generators this only contains upvars that are shared by all states.
1036- fn closure_saved_names_of_captured_variables ( tcx : TyCtxt < ' _ > , def_id : DefId ) -> SmallVec < String > {
1037- let body = tcx. optimized_mir ( def_id) ;
1038-
1039- body. var_debug_info
1040- . iter ( )
1041- . filter_map ( |var| {
1042- let is_ref = match var. value {
1043- mir:: VarDebugInfoContents :: Place ( place) if place. local == mir:: Local :: new ( 1 ) => {
1044- // The projection is either `[.., Field, Deref]` or `[.., Field]`. It
1045- // implies whether the variable is captured by value or by reference.
1046- matches ! ( place. projection. last( ) . unwrap( ) , mir:: ProjectionElem :: Deref )
1047- }
1048- _ => return None ,
1049- } ;
1050- let prefix = if is_ref { "_ref__" } else { "" } ;
1051- Some ( prefix. to_owned ( ) + var. name . as_str ( ) )
1052- } )
1053- . collect ( )
1054- }
1055-
10561027/// Builds the DW_TAG_member debuginfo nodes for the upvars of a closure or generator.
10571028/// For a generator, this will handle upvars shared by all states.
10581029fn build_upvar_field_di_nodes < ' ll , ' tcx > (
@@ -1083,7 +1054,7 @@ fn build_upvar_field_di_nodes<'ll, 'tcx>(
10831054 . all( |& t| t == cx. tcx. normalize_erasing_regions( ParamEnv :: reveal_all( ) , t) )
10841055 ) ;
10851056
1086- let capture_names = closure_saved_names_of_captured_variables ( cx. tcx , def_id) ;
1057+ let capture_names = cx. tcx . closure_saved_names_of_captured_variables ( def_id) ;
10871058 let layout = cx. layout_of ( closure_or_generator_ty) ;
10881059
10891060 up_var_tys
@@ -1229,43 +1200,6 @@ fn build_union_type_di_node<'ll, 'tcx>(
12291200 )
12301201}
12311202
1232- // FIXME(eddyb) maybe precompute this? Right now it's computed once
1233- // per generator monomorphization, but it doesn't depend on substs.
1234- fn generator_layout_and_saved_local_names < ' tcx > (
1235- tcx : TyCtxt < ' tcx > ,
1236- def_id : DefId ,
1237- ) -> ( & ' tcx GeneratorLayout < ' tcx > , IndexVec < mir:: GeneratorSavedLocal , Option < Symbol > > ) {
1238- let body = tcx. optimized_mir ( def_id) ;
1239- let generator_layout = body. generator_layout ( ) . unwrap ( ) ;
1240- let mut generator_saved_local_names = IndexVec :: from_elem ( None , & generator_layout. field_tys ) ;
1241-
1242- let state_arg = mir:: Local :: new ( 1 ) ;
1243- for var in & body. var_debug_info {
1244- let mir:: VarDebugInfoContents :: Place ( place) = & var. value else { continue } ;
1245- if place. local != state_arg {
1246- continue ;
1247- }
1248- match place. projection [ ..] {
1249- [
1250- // Deref of the `Pin<&mut Self>` state argument.
1251- mir:: ProjectionElem :: Field ( ..) ,
1252- mir:: ProjectionElem :: Deref ,
1253- // Field of a variant of the state.
1254- mir:: ProjectionElem :: Downcast ( _, variant) ,
1255- mir:: ProjectionElem :: Field ( field, _) ,
1256- ] => {
1257- let name = & mut generator_saved_local_names
1258- [ generator_layout. variant_fields [ variant] [ field] ] ;
1259- if name. is_none ( ) {
1260- name. replace ( var. name ) ;
1261- }
1262- }
1263- _ => { }
1264- }
1265- }
1266- ( generator_layout, generator_saved_local_names)
1267- }
1268-
12691203/// Computes the type parameters for a type, if any, for the given metadata.
12701204fn build_generic_type_param_di_nodes < ' ll , ' tcx > (
12711205 cx : & CodegenCx < ' ll , ' tcx > ,
0 commit comments