@@ -56,14 +56,20 @@ pub(super) fn build_enum_type_di_node<'ll, 'tcx>(
56
56
57
57
assert ! ( !wants_c_like_enum_debuginfo( cx. tcx, enum_type_and_layout) ) ;
58
58
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
+
59
65
type_map:: build_type_with_children (
60
66
cx,
61
67
type_map:: stub (
62
68
cx,
63
69
Stub :: Struct ,
64
70
unique_type_id,
65
71
& enum_type_name,
66
- Some ( file_metadata_from_def_id ( cx , Some ( enum_adt_def . did ( ) ) ) ) ,
72
+ def_location ,
67
73
size_and_align_of ( enum_type_and_layout) ,
68
74
Some ( containing_scope) ,
69
75
visibility_flags,
@@ -86,18 +92,29 @@ pub(super) fn build_enum_type_di_node<'ll, 'tcx>(
86
92
enum_type_and_layout. for_variant ( cx, variant_index) ,
87
93
visibility_flags,
88
94
) ,
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
+ } ,
93
104
} )
94
105
. collect ( ) ;
95
106
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
+ } ;
96
113
smallvec ! [ build_enum_variant_part_di_node(
97
114
cx,
98
115
enum_type_and_layout,
99
116
enum_type_di_node,
100
- enum_adt_def . did ( ) ,
117
+ enum_adt_def_id ,
101
118
& variant_member_infos[ ..] ,
102
119
) ]
103
120
} ,
@@ -210,6 +227,12 @@ pub(super) fn build_coroutine_di_node<'ll, 'tcx>(
210
227
} )
211
228
. collect ( ) ;
212
229
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
+ } ;
213
236
smallvec ! [ build_enum_variant_part_di_node(
214
237
cx,
215
238
coroutine_type_and_layout,
@@ -242,7 +265,7 @@ fn build_enum_variant_part_di_node<'ll, 'tcx>(
242
265
cx : & CodegenCx < ' ll , ' tcx > ,
243
266
enum_type_and_layout : TyAndLayout < ' tcx > ,
244
267
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 > ,
246
269
variant_member_infos : & [ VariantMemberInfo < ' _ , ' ll > ] ,
247
270
) -> & ' ll DIType {
248
271
let tag_member_di_node =
@@ -253,7 +276,7 @@ fn build_enum_variant_part_di_node<'ll, 'tcx>(
253
276
254
277
let ( file_metadata, line_number) =
255
278
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)
257
280
} else {
258
281
( unknown_file_metadata ( cx) , UNKNOWN_LINE_NUMBER )
259
282
} ;
0 commit comments