about summary refs log tree commit diff
path: root/compiler/rustc_codegen_cranelift/src/debuginfo
diff options
context:
space:
mode:
authorDavid Wood <david.wood@huawei.com>2022-07-21 16:19:22 +0100
committerDavid Wood <david.wood@huawei.com>2022-09-07 13:54:51 +0100
commit38958aa8bdd2b46dd7f9213bda1c9c6433282a68 (patch)
tree52b8d6634559b28453878c037cc616b73e77048f /compiler/rustc_codegen_cranelift/src/debuginfo
parent2991a7c7153946e02db0928eb5bfb2a53607219f (diff)
downloadrust-38958aa8bdd2b46dd7f9213bda1c9c6433282a68.tar.gz
rust-38958aa8bdd2b46dd7f9213bda1c9c6433282a68.zip
ssa: implement `#[collapse_debuginfo]`
Debuginfo line information for macro invocations are collapsed by
default - line information are replaced by the line of the outermost
expansion site. Using `-Zdebug-macros` disables this behaviour.

When the `collapse_debuginfo` feature is enabled, the default behaviour
is reversed so that debuginfo is not collapsed by default. In addition,
the `#[collapse_debuginfo]` attribute is available and can be applied to
macro definitions which will then have their line information collapsed.

Signed-off-by: David Wood <david.wood@huawei.com>
Diffstat (limited to 'compiler/rustc_codegen_cranelift/src/debuginfo')
-rw-r--r--compiler/rustc_codegen_cranelift/src/debuginfo/line_info.rs6
1 files changed, 3 insertions, 3 deletions
diff --git a/compiler/rustc_codegen_cranelift/src/debuginfo/line_info.rs b/compiler/rustc_codegen_cranelift/src/debuginfo/line_info.rs
index 3ad0c420eaf..463de6a91c7 100644
--- a/compiler/rustc_codegen_cranelift/src/debuginfo/line_info.rs
+++ b/compiler/rustc_codegen_cranelift/src/debuginfo/line_info.rs
@@ -68,9 +68,9 @@ impl DebugContext {
     ) -> (Lrc<SourceFile>, 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
-        // (unless the crate is being compiled with `-Z debug-macros`).
-        let span = if !span.from_expansion() || tcx.sess.opts.unstable_opts.debug_macros {
+        // 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 = if tcx.should_collapse_debuginfo(span) {
             span
         } else {
             // Walk up the macro expansion chain until we reach a non-expanded span.