@@ -27,9 +27,7 @@ use rustc_codegen_ssa::traits::*;
27
27
use rustc_fs_util:: path_to_c_string;
28
28
use rustc_hir:: def:: CtorKind ;
29
29
use rustc_hir:: def_id:: { DefId , LOCAL_CRATE } ;
30
- use rustc_index:: vec:: { Idx , IndexVec } ;
31
30
use rustc_middle:: bug;
32
- use rustc_middle:: mir:: { self , GeneratorLayout } ;
33
31
use rustc_middle:: ty:: layout:: { LayoutOf , TyAndLayout } ;
34
32
use rustc_middle:: ty:: subst:: GenericArgKind ;
35
33
use rustc_middle:: ty:: {
@@ -1026,33 +1024,6 @@ fn build_struct_type_di_node<'ll, 'tcx>(
1026
1024
// Tuples
1027
1025
//=-----------------------------------------------------------------------------
1028
1026
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
-
1056
1027
/// Builds the DW_TAG_member debuginfo nodes for the upvars of a closure or generator.
1057
1028
/// For a generator, this will handle upvars shared by all states.
1058
1029
fn build_upvar_field_di_nodes < ' ll , ' tcx > (
@@ -1083,7 +1054,7 @@ fn build_upvar_field_di_nodes<'ll, 'tcx>(
1083
1054
. all( |& t| t == cx. tcx. normalize_erasing_regions( ParamEnv :: reveal_all( ) , t) )
1084
1055
) ;
1085
1056
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) ;
1087
1058
let layout = cx. layout_of ( closure_or_generator_ty) ;
1088
1059
1089
1060
up_var_tys
@@ -1229,43 +1200,6 @@ fn build_union_type_di_node<'ll, 'tcx>(
1229
1200
)
1230
1201
}
1231
1202
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
-
1269
1203
/// Computes the type parameters for a type, if any, for the given metadata.
1270
1204
fn build_generic_type_param_di_nodes < ' ll , ' tcx > (
1271
1205
cx : & CodegenCx < ' ll , ' tcx > ,
0 commit comments