about summary refs log tree commit diff
diff options
context:
space:
mode:
authorVadim Petrochenkov <vadim.petrochenkov@gmail.com>2024-02-09 15:39:25 +0300
committerVadim Petrochenkov <vadim.petrochenkov@gmail.com>2024-04-25 22:14:47 +0300
commit9a57c636e7e147184fa061aefdbb4086b305dadc (patch)
treeabace4deb4d8c400788ab00cbe2c56f2625dccf6
parentdda4709b1cba078ab05a32aa9c9359537e0ae0ad (diff)
downloadrust-9a57c636e7e147184fa061aefdbb4086b305dadc.tar.gz
rust-9a57c636e7e147184fa061aefdbb4086b305dadc.zip
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.
-rw-r--r--src/debuginfo/line_info.rs9
1 files changed, 3 insertions, 6 deletions
diff --git a/src/debuginfo/line_info.rs b/src/debuginfo/line_info.rs
index 32b9c824ded..78b3d5a58f4 100644
--- a/src/debuginfo/line_info.rs
+++ b/src/debuginfo/line_info.rs
@@ -7,7 +7,7 @@ use cranelift_codegen::binemit::CodeOffset;
 use cranelift_codegen::MachSrcLoc;
 use gimli::write::{AttributeValue, FileId, FileInfo, LineProgram, LineString, LineStringTable};
 use rustc_span::{
-    FileName, Pos, SourceFile, SourceFileAndLine, SourceFileHash, SourceFileHashAlgorithm,
+    hygiene, FileName, Pos, SourceFile, SourceFileAndLine, SourceFileHash, SourceFileHashAlgorithm,
 };
 
 use crate::debuginfo::emit::address_for_func;
@@ -63,11 +63,8 @@ impl DebugContext {
         function_span: Span,
         span: Span,
     ) -> (FileId, u64, u64) {
-        // Based on https://github.com/rust-lang/rust/blob/e369d87b015a84653343032833d65d0545fd3f26/src/librustc_codegen_ssa/mir/mod.rs#L116-L131
-        // In order to have a good line stepping behavior in debugger, we overwrite debug
-        // locations of macro expansions with that of the outermost expansion site (when the macro is
-        // annotated with `#[collapse_debuginfo]` or when `-Zdebug-macros` is provided).
-        let span = tcx.collapsed_debuginfo(span, function_span);
+        // Match behavior of `FunctionCx::adjusted_span_and_dbg_scope`.
+        let span = hygiene::walk_chain_collapsed(span, function_span);
         match tcx.sess.source_map().lookup_line(span.lo()) {
             Ok(SourceFileAndLine { sf: file, line }) => {
                 let file_id = self.add_source_file(&file);