Skip to content

Commit 9a57c63

Browse files
committed
debuginfo: Stabilize -Z debug-macros, -Z collapse-macro-debuginfo and #[collapse_debuginfo]
`-Z debug-macros` is "stabilized" by enabling it by default and removing. `-Z collapse-macro-debuginfo` is stabilized as `-C collapse-macro-debuginfo`. It now supports all typical boolean values (`parse_opt_bool`) in addition to just yes/no. Default value of `collapse_debuginfo` was changed from `false` to `external` (i.e. collapsed if external, not collapsed if local). `#[collapse_debuginfo]` attribute without a value is no longer supported to avoid guessing the default.
1 parent dda4709 commit 9a57c63

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

src/debuginfo/line_info.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use cranelift_codegen::binemit::CodeOffset;
77
use cranelift_codegen::MachSrcLoc;
88
use gimli::write::{AttributeValue, FileId, FileInfo, LineProgram, LineString, LineStringTable};
99
use rustc_span::{
10-
FileName, Pos, SourceFile, SourceFileAndLine, SourceFileHash, SourceFileHashAlgorithm,
10+
hygiene, FileName, Pos, SourceFile, SourceFileAndLine, SourceFileHash, SourceFileHashAlgorithm,
1111
};
1212

1313
use crate::debuginfo::emit::address_for_func;
@@ -63,11 +63,8 @@ impl DebugContext {
6363
function_span: Span,
6464
span: Span,
6565
) -> (FileId, u64, u64) {
66-
// Based on https://github.com/rust-lang/rust/blob/e369d87b015a84653343032833d65d0545fd3f26/src/librustc_codegen_ssa/mir/mod.rs#L116-L131
67-
// In order to have a good line stepping behavior in debugger, we overwrite debug
68-
// locations of macro expansions with that of the outermost expansion site (when the macro is
69-
// annotated with `#[collapse_debuginfo]` or when `-Zdebug-macros` is provided).
70-
let span = tcx.collapsed_debuginfo(span, function_span);
66+
// Match behavior of `FunctionCx::adjusted_span_and_dbg_scope`.
67+
let span = hygiene::walk_chain_collapsed(span, function_span);
7168
match tcx.sess.source_map().lookup_line(span.lo()) {
7269
Ok(SourceFileAndLine { sf: file, line }) => {
7370
let file_id = self.add_source_file(&file);

0 commit comments

Comments
 (0)