Skip to content

Commit 21c58b1

Browse files
committed
Rename option and add doc
1 parent 4692d46 commit 21c58b1

File tree

11 files changed

+54
-52
lines changed

11 files changed

+54
-52
lines changed

compiler/rustc_codegen_llvm/src/debuginfo/metadata.rs

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -998,12 +998,12 @@ fn build_field_di_node<'ll, 'tcx>(
998998
type_di_node: &'ll DIType,
999999
def_id: Option<DefId>,
10001000
) -> &'ll DIType {
1001-
let (file_metadata, line_number) =
1002-
if cx.sess().opts.unstable_opts.more_source_locations_in_debuginfo {
1003-
file_metadata_from_def_id(cx, def_id)
1004-
} else {
1005-
(unknown_file_metadata(cx), UNKNOWN_LINE_NUMBER)
1006-
};
1001+
let (file_metadata, line_number) = if cx.sess().opts.unstable_opts.debug_info_type_line_numbers
1002+
{
1003+
file_metadata_from_def_id(cx, def_id)
1004+
} else {
1005+
(unknown_file_metadata(cx), UNKNOWN_LINE_NUMBER)
1006+
};
10071007
unsafe {
10081008
llvm::LLVMRustDIBuilderCreateMemberType(
10091009
DIB(cx),
@@ -1055,7 +1055,7 @@ fn build_struct_type_di_node<'ll, 'tcx>(
10551055
let containing_scope = get_namespace_for_item(cx, adt_def.did());
10561056
let struct_type_and_layout = cx.layout_of(struct_type);
10571057
let variant_def = adt_def.non_enum_variant();
1058-
let def_location = if cx.sess().opts.unstable_opts.more_source_locations_in_debuginfo {
1058+
let def_location = if cx.sess().opts.unstable_opts.debug_info_type_line_numbers {
10591059
Some(file_metadata_from_def_id(cx, Some(adt_def.did())))
10601060
} else {
10611061
None
@@ -1088,8 +1088,7 @@ fn build_struct_type_di_node<'ll, 'tcx>(
10881088
Cow::Borrowed(f.name.as_str())
10891089
};
10901090
let field_layout = struct_type_and_layout.field(cx, i);
1091-
let def_id = if cx.sess().opts.unstable_opts.more_source_locations_in_debuginfo
1092-
{
1091+
let def_id = if cx.sess().opts.unstable_opts.debug_info_type_line_numbers {
10931092
Some(f.did)
10941093
} else {
10951094
None
@@ -1221,7 +1220,7 @@ fn build_closure_env_di_node<'ll, 'tcx>(
12211220
let containing_scope = get_namespace_for_item(cx, def_id);
12221221
let type_name = compute_debuginfo_type_name(cx.tcx, closure_env_type, false);
12231222

1224-
let def_location = if cx.sess().opts.unstable_opts.more_source_locations_in_debuginfo {
1223+
let def_location = if cx.sess().opts.unstable_opts.debug_info_type_line_numbers {
12251224
Some(file_metadata_from_def_id(cx, Some(def_id)))
12261225
} else {
12271226
None
@@ -1258,7 +1257,7 @@ fn build_union_type_di_node<'ll, 'tcx>(
12581257
let containing_scope = get_namespace_for_item(cx, union_def_id);
12591258
let union_ty_and_layout = cx.layout_of(union_type);
12601259
let type_name = compute_debuginfo_type_name(cx.tcx, union_type, false);
1261-
let def_location = if cx.sess().opts.unstable_opts.more_source_locations_in_debuginfo {
1260+
let def_location = if cx.sess().opts.unstable_opts.debug_info_type_line_numbers {
12621261
Some(file_metadata_from_def_id(cx, Some(union_def_id)))
12631262
} else {
12641263
None
@@ -1284,8 +1283,7 @@ fn build_union_type_di_node<'ll, 'tcx>(
12841283
.enumerate()
12851284
.map(|(i, f)| {
12861285
let field_layout = union_ty_and_layout.field(cx, i);
1287-
let def_id = if cx.sess().opts.unstable_opts.more_source_locations_in_debuginfo
1288-
{
1286+
let def_id = if cx.sess().opts.unstable_opts.debug_info_type_line_numbers {
12891287
Some(f.did)
12901288
} else {
12911289
None

compiler/rustc_codegen_llvm/src/debuginfo/metadata/enums/cpp_like.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ pub(super) fn build_enum_type_di_node<'ll, 'tcx>(
192192

193193
assert!(!wants_c_like_enum_debuginfo(cx.tcx, enum_type_and_layout));
194194

195-
let def_location = if cx.sess().opts.unstable_opts.more_source_locations_in_debuginfo {
195+
let def_location = if cx.sess().opts.unstable_opts.debug_info_type_line_numbers {
196196
Some(file_metadata_from_def_id(cx, Some(enum_adt_def.did())))
197197
} else {
198198
None
@@ -269,7 +269,7 @@ pub(super) fn build_coroutine_di_node<'ll, 'tcx>(
269269
unique_type_id: UniqueTypeId<'tcx>,
270270
) -> DINodeCreationResult<'ll> {
271271
let coroutine_type = unique_type_id.expect_ty();
272-
let def_location = if cx.sess().opts.unstable_opts.more_source_locations_in_debuginfo {
272+
let def_location = if cx.sess().opts.unstable_opts.debug_info_type_line_numbers {
273273
let &ty::Coroutine(coroutine_def_id, _) = coroutine_type.kind() else {
274274
bug!("build_coroutine_di_node() called with non-coroutine type: `{:?}`", coroutine_type)
275275
};
@@ -337,7 +337,7 @@ fn build_single_variant_union_fields<'ll, 'tcx>(
337337
let tag_base_type_di_node = type_di_node(cx, tag_base_type);
338338
let tag_base_type_align = cx.align_of(tag_base_type);
339339

340-
let enum_adt_def_id = if cx.sess().opts.unstable_opts.more_source_locations_in_debuginfo {
340+
let enum_adt_def_id = if cx.sess().opts.unstable_opts.debug_info_type_line_numbers {
341341
Some(enum_adt_def.did())
342342
} else {
343343
None
@@ -408,7 +408,7 @@ fn build_union_fields_for_enum<'ll, 'tcx>(
408408
) -> SmallVec<&'ll DIType> {
409409
let tag_base_type = tag_base_type(cx.tcx, enum_type_and_layout);
410410

411-
let enum_adt_def_id = if cx.sess().opts.unstable_opts.more_source_locations_in_debuginfo {
411+
let enum_adt_def_id = if cx.sess().opts.unstable_opts.debug_info_type_line_numbers {
412412
Some(enum_adt_def.did())
413413
} else {
414414
None
@@ -721,7 +721,7 @@ fn build_union_fields_for_direct_tag_coroutine<'ll, 'tcx>(
721721
variant_range
722722
.clone()
723723
.map(|variant_index| (variant_index, CoroutineArgs::variant_name(variant_index))),
724-
if cx.sess().opts.unstable_opts.more_source_locations_in_debuginfo {
724+
if cx.sess().opts.unstable_opts.debug_info_type_line_numbers {
725725
Some(coroutine_def_id)
726726
} else {
727727
None
@@ -818,7 +818,7 @@ fn build_union_fields_for_direct_tag_enum_or_coroutine<'ll, 'tcx>(
818818
tag_base_type_di_node,
819819
tag_base_type,
820820
variant_member_info.discr,
821-
if cx.sess().opts.unstable_opts.more_source_locations_in_debuginfo {
821+
if cx.sess().opts.unstable_opts.debug_info_type_line_numbers {
822822
variant_member_info.source_info
823823
} else {
824824
None

compiler/rustc_codegen_llvm/src/debuginfo/metadata/enums/mod.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ fn build_c_style_enum_di_node<'ll, 'tcx>(
6868
enum_type_and_layout: TyAndLayout<'tcx>,
6969
) -> DINodeCreationResult<'ll> {
7070
let containing_scope = get_namespace_for_item(cx, enum_adt_def.did());
71-
let enum_adt_def_id = if cx.sess().opts.unstable_opts.more_source_locations_in_debuginfo {
71+
let enum_adt_def_id = if cx.sess().opts.unstable_opts.debug_info_type_line_numbers {
7272
Some(enum_adt_def.did())
7373
} else {
7474
None
@@ -122,12 +122,12 @@ fn build_enumeration_type_di_node<'ll, 'tcx>(
122122
})
123123
.collect();
124124

125-
let (file_metadata, line_number) =
126-
if cx.sess().opts.unstable_opts.more_source_locations_in_debuginfo {
127-
file_metadata_from_def_id(cx, def_id)
128-
} else {
129-
(unknown_file_metadata(cx), UNKNOWN_LINE_NUMBER)
130-
};
125+
let (file_metadata, line_number) = if cx.sess().opts.unstable_opts.debug_info_type_line_numbers
126+
{
127+
file_metadata_from_def_id(cx, def_id)
128+
} else {
129+
(unknown_file_metadata(cx), UNKNOWN_LINE_NUMBER)
130+
};
131131

132132
unsafe {
133133
llvm::LLVMRustDIBuilderCreateEnumerationType(
@@ -207,7 +207,7 @@ fn build_enum_variant_struct_type_di_node<'ll, 'tcx>(
207207
) -> &'ll DIType {
208208
assert_eq!(variant_layout.ty, enum_type_and_layout.ty);
209209

210-
let def_location = if cx.sess().opts.unstable_opts.more_source_locations_in_debuginfo {
210+
let def_location = if cx.sess().opts.unstable_opts.debug_info_type_line_numbers {
211211
Some(file_metadata_from_def_id(cx, Some(variant_def.def_id)))
212212
} else {
213213
None

compiler/rustc_codegen_llvm/src/debuginfo/metadata/enums/native.rs

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ 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 {
59+
let def_location = if cx.sess().opts.unstable_opts.debug_info_type_line_numbers {
6060
Some(file_metadata_from_def_id(cx, Some(enum_adt_def.did())))
6161
} else {
6262
None
@@ -92,8 +92,7 @@ pub(super) fn build_enum_type_di_node<'ll, 'tcx>(
9292
enum_type_and_layout.for_variant(cx, variant_index),
9393
visibility_flags,
9494
),
95-
source_info: if cx.sess().opts.unstable_opts.more_source_locations_in_debuginfo
96-
{
95+
source_info: if cx.sess().opts.unstable_opts.debug_info_type_line_numbers {
9796
Some(file_metadata_from_def_id(
9897
cx,
9998
Some(enum_adt_def.variant(variant_index).def_id),
@@ -104,8 +103,7 @@ pub(super) fn build_enum_type_di_node<'ll, 'tcx>(
104103
})
105104
.collect();
106105

107-
let enum_adt_def_id = if cx.sess().opts.unstable_opts.more_source_locations_in_debuginfo
108-
{
106+
let enum_adt_def_id = if cx.sess().opts.unstable_opts.debug_info_type_line_numbers {
109107
Some(enum_adt_def.did())
110108
} else {
111109
None
@@ -157,7 +155,7 @@ pub(super) fn build_coroutine_di_node<'ll, 'tcx>(
157155

158156
let coroutine_type_name = compute_debuginfo_type_name(cx.tcx, coroutine_type, false);
159157

160-
let def_location = if cx.sess().opts.unstable_opts.more_source_locations_in_debuginfo {
158+
let def_location = if cx.sess().opts.unstable_opts.debug_info_type_line_numbers {
161159
Some(file_metadata_from_def_id(cx, Some(coroutine_def_id)))
162160
} else {
163161
None
@@ -227,12 +225,11 @@ pub(super) fn build_coroutine_di_node<'ll, 'tcx>(
227225
})
228226
.collect();
229227

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-
};
228+
let coroutine_def_id = if cx.sess().opts.unstable_opts.debug_info_type_line_numbers {
229+
Some(coroutine_def_id)
230+
} else {
231+
None
232+
};
236233
smallvec![build_enum_variant_part_di_node(
237234
cx,
238235
coroutine_type_and_layout,
@@ -274,12 +271,12 @@ fn build_enum_variant_part_di_node<'ll, 'tcx>(
274271
let variant_part_unique_type_id =
275272
UniqueTypeId::for_enum_variant_part(cx.tcx, enum_type_and_layout.ty);
276273

277-
let (file_metadata, line_number) =
278-
if cx.sess().opts.unstable_opts.more_source_locations_in_debuginfo {
279-
file_metadata_from_def_id(cx, enum_type_def_id)
280-
} else {
281-
(unknown_file_metadata(cx), UNKNOWN_LINE_NUMBER)
282-
};
274+
let (file_metadata, line_number) = if cx.sess().opts.unstable_opts.debug_info_type_line_numbers
275+
{
276+
file_metadata_from_def_id(cx, enum_type_def_id)
277+
} else {
278+
(unknown_file_metadata(cx), UNKNOWN_LINE_NUMBER)
279+
};
283280

284281
let stub = StubInfo::new(
285282
cx,

compiler/rustc_interface/src/tests.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -709,7 +709,6 @@ fn test_unstable_options_tracking_hash() {
709709
untracked!(macro_backtrace, true);
710710
untracked!(meta_stats, true);
711711
untracked!(mir_include_spans, MirIncludeSpans::On);
712-
untracked!(more_source_locations_in_debuginfo, true);
713712
untracked!(nll_facts, true);
714713
untracked!(no_analysis, true);
715714
untracked!(no_leak_check, true);
@@ -773,6 +772,7 @@ fn test_unstable_options_tracking_hash() {
773772
tracked!(crate_attr, vec!["abc".to_string()]);
774773
tracked!(cross_crate_inline_threshold, InliningThreshold::Always);
775774
tracked!(debug_info_for_profiling, true);
775+
tracked!(debug_info_type_line_numbers, true);
776776
tracked!(default_visibility, Some(rustc_target::spec::SymbolVisibility::Hidden));
777777
tracked!(dep_info_omit_d_target, true);
778778
tracked!(direct_access_external_data, Some(true));

compiler/rustc_session/src/options.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1714,6 +1714,8 @@ options! {
17141714
"threshold to allow cross crate inlining of functions"),
17151715
debug_info_for_profiling: bool = (false, parse_bool, [TRACKED],
17161716
"emit discriminators and other data necessary for AutoFDO"),
1717+
debug_info_type_line_numbers: bool = (false, parse_bool, [TRACKED],
1718+
"emit type and line information for additional data types (default: no)"),
17171719
debuginfo_compression: DebugInfoCompression = (DebugInfoCompression::None, parse_debuginfo_compression, [TRACKED],
17181720
"compress debug info sections (none, zlib, zstd, default: none)"),
17191721
deduplicate_diagnostics: bool = (true, parse_bool, [UNTRACKED],
@@ -1907,8 +1909,6 @@ options! {
19071909
#[rustc_lint_opt_deny_field_access("use `Session::mir_opt_level` instead of this field")]
19081910
mir_opt_level: Option<usize> = (None, parse_opt_number, [TRACKED],
19091911
"MIR optimization level (0-4; default: 1 in non optimized builds and 2 in optimized builds)"),
1910-
more_source_locations_in_debuginfo: bool = (false, parse_bool, [UNTRACKED],
1911-
"include additional source file and line number information in debuginfo (default: no)"),
19121912
move_size_limit: Option<usize> = (None, parse_opt_number, [TRACKED],
19131913
"the size at which the `large_assignments` lint starts to be emitted"),
19141914
mutable_noalias: bool = (true, parse_bool, [TRACKED],
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# `debug-info-type-line-numbers`
2+
3+
---
4+
5+
This option causes additional type and line information to be emitted in debug
6+
info to provide richer information to debuggers. This is currently off by
7+
default as it causes some compilation scenarios to be noticeably slower.

tests/codegen/issues/issue-98678-async.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// async functions.
33
//
44
// edition: 2021
5-
// compile-flags: -C debuginfo=2 -Z more-source-locations-in-debuginfo=true
5+
// compile-flags: -C debuginfo=2 -Z debug-info-type-line-numbers=true
66
#![crate_type = "lib"]
77

88
// ignore-tidy-linelength

tests/codegen/issues/issue-98678-closure-generator.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// This test verifies the accuracy of emitted file and line debuginfo metadata for closures and
22
// generators.
33
//
4-
// compile-flags: -C debuginfo=2 -Z more-source-locations-in-debuginfo
4+
// compile-flags: -C debuginfo=2 -Z debug-info-type-line-numbers=true
55
#![crate_type = "lib"]
66
#![feature(generators, stmt_expr_attributes)]
77

tests/codegen/issues/issue-98678-enum.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// This test verifies the accuracy of emitted file and line debuginfo metadata enums.
22
//
3-
// compile-flags: -C debuginfo=2 -Z more-source-locations-in-debuginfo
3+
// compile-flags: -C debuginfo=2 -Z debug-info-type-line-numbers=true
44
#![crate_type = "lib"]
55

66
// ignore-tidy-linelength

tests/codegen/issues/issue-98678-struct-union.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// This test verifies the accuracy of emitted file and line debuginfo metadata for structs and
22
// unions.
33
//
4-
// compile-flags: -C debuginfo=2 -Z more-source-locations-in-debuginfo
4+
// compile-flags: -C debuginfo=2 -Z debug-info-type-line-numbers=true
55
#![crate_type = "lib"]
66

77
// ignore-tidy-linelength

0 commit comments

Comments
 (0)