@@ -56,14 +56,20 @@ pub(super) fn build_enum_type_di_node<'ll, 'tcx>(
5656
5757 assert ! ( !wants_c_like_enum_debuginfo( cx. tcx, enum_type_and_layout) ) ;
5858
59+ let def_location = if cx. sess ( ) . opts . unstable_opts . more_source_locations_in_debuginfo {
60+ Some ( file_metadata_from_def_id ( cx, Some ( enum_adt_def. did ( ) ) ) )
61+ } else {
62+ None
63+ } ;
64+
5965 type_map:: build_type_with_children (
6066 cx,
6167 type_map:: stub (
6268 cx,
6369 Stub :: Struct ,
6470 unique_type_id,
6571 & enum_type_name,
66- Some ( file_metadata_from_def_id ( cx , Some ( enum_adt_def . did ( ) ) ) ) ,
72+ def_location ,
6773 size_and_align_of ( enum_type_and_layout) ,
6874 Some ( containing_scope) ,
6975 visibility_flags,
@@ -86,18 +92,29 @@ pub(super) fn build_enum_type_di_node<'ll, 'tcx>(
8692 enum_type_and_layout. for_variant ( cx, variant_index) ,
8793 visibility_flags,
8894 ) ,
89- source_info : Some ( file_metadata_from_def_id (
90- cx,
91- Some ( enum_adt_def. variant ( variant_index) . def_id ) ,
92- ) ) ,
95+ source_info : if cx. sess ( ) . opts . unstable_opts . more_source_locations_in_debuginfo
96+ {
97+ Some ( file_metadata_from_def_id (
98+ cx,
99+ Some ( enum_adt_def. variant ( variant_index) . def_id ) ,
100+ ) )
101+ } else {
102+ None
103+ } ,
93104 } )
94105 . collect ( ) ;
95106
107+ let enum_adt_def_id = if cx. sess ( ) . opts . unstable_opts . more_source_locations_in_debuginfo
108+ {
109+ Some ( enum_adt_def. did ( ) )
110+ } else {
111+ None
112+ } ;
96113 smallvec ! [ build_enum_variant_part_di_node(
97114 cx,
98115 enum_type_and_layout,
99116 enum_type_di_node,
100- enum_adt_def . did ( ) ,
117+ enum_adt_def_id ,
101118 & variant_member_infos[ ..] ,
102119 ) ]
103120 } ,
@@ -210,6 +227,12 @@ pub(super) fn build_coroutine_di_node<'ll, 'tcx>(
210227 } )
211228 . collect ( ) ;
212229
230+ let generator_def_id =
231+ if cx. sess ( ) . opts . unstable_opts . more_source_locations_in_debuginfo {
232+ Some ( generator_def_id)
233+ } else {
234+ None
235+ } ;
213236 smallvec ! [ build_enum_variant_part_di_node(
214237 cx,
215238 coroutine_type_and_layout,
@@ -242,7 +265,7 @@ fn build_enum_variant_part_di_node<'ll, 'tcx>(
242265 cx : & CodegenCx < ' ll , ' tcx > ,
243266 enum_type_and_layout : TyAndLayout < ' tcx > ,
244267 enum_type_di_node : & ' ll DIType ,
245- enum_type_def_id : rustc_span:: def_id:: DefId ,
268+ enum_type_def_id : Option < rustc_span:: def_id:: DefId > ,
246269 variant_member_infos : & [ VariantMemberInfo < ' _ , ' ll > ] ,
247270) -> & ' ll DIType {
248271 let tag_member_di_node =
@@ -253,7 +276,7 @@ fn build_enum_variant_part_di_node<'ll, 'tcx>(
253276
254277 let ( file_metadata, line_number) =
255278 if cx. sess ( ) . opts . unstable_opts . more_source_locations_in_debuginfo {
256- file_metadata_from_def_id ( cx, Some ( enum_type_def_id) )
279+ file_metadata_from_def_id ( cx, enum_type_def_id)
257280 } else {
258281 ( unknown_file_metadata ( cx) , UNKNOWN_LINE_NUMBER )
259282 } ;
0 commit comments