Skip to content

Commit

Permalink
Auto merge of #120845 - petrochenkov:debmac, r=oli-obk
Browse files Browse the repository at this point in the history
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) - rust-lang/rust#100758 (comment) describes some debugging scenarios that motivate this default as reasonable.
`#[collapse_debuginfo]` attribute without a value is no longer supported to avoid guessing the default.

Stabilization report: rust-lang/rust#120845 (comment)

Closes rust-lang/rust#100758
Closes rust-lang/rust#41743
Closes rust-lang/rust#39153
  • Loading branch information
bors committed Apr 26, 2024
2 parents 664e7fa + b57428c commit f36a5b9
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 9 deletions.
10 changes: 3 additions & 7 deletions src/shims/backtrace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use crate::*;
use rustc_ast::ast::Mutability;
use rustc_middle::ty::layout::LayoutOf as _;
use rustc_middle::ty::{self, Instance, Ty};
use rustc_span::{BytePos, Loc, Symbol};
use rustc_span::{hygiene, BytePos, Loc, Symbol};
use rustc_target::{abi::Size, spec::abi::Abi};

impl<'mir, 'tcx: 'mir> EvalContextExt<'mir, 'tcx> for crate::MiriInterpCx<'mir, 'tcx> {}
Expand Down Expand Up @@ -45,12 +45,8 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {

let mut data = Vec::new();
for frame in this.active_thread_stack().iter().rev() {
let mut span = frame.current_span();
// Match the behavior of runtime backtrace spans
// by using a non-macro span in our backtrace. See `FunctionCx::debug_loc`.
if span.from_expansion() && !tcx.sess.opts.unstable_opts.debug_macros {
span = rustc_span::hygiene::walk_chain(span, frame.body.span.ctxt())
}
// Match behavior of debuginfo (`FunctionCx::adjusted_span_and_dbg_scope`).
let span = hygiene::walk_chain_collapsed(frame.current_span(), frame.body.span);
data.push((frame.instance, span.lo()));
}

Expand Down
2 changes: 1 addition & 1 deletion tests/pass/backtrace/backtrace-api-v0.stdout
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
$DIR/backtrace-api-v0.rs:24:14 (func_d)
$DIR/backtrace-api-v0.rs:20:5 (func_c)
$DIR/backtrace-api-v0.rs:14:9 (func_c)
$DIR/backtrace-api-v0.rs:9:5 (func_b::<u8>)
$DIR/backtrace-api-v0.rs:5:5 (func_a)
$DIR/backtrace-api-v0.rs:29:18 (main)
2 changes: 1 addition & 1 deletion tests/pass/backtrace/backtrace-api-v1.stdout
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
$DIR/backtrace-api-v1.rs:27:9 (func_d)
$DIR/backtrace-api-v1.rs:20:5 (func_c)
$DIR/backtrace-api-v1.rs:14:9 (func_c)
$DIR/backtrace-api-v1.rs:9:5 (func_b::<u8>)
$DIR/backtrace-api-v1.rs:5:5 (func_a)
$DIR/backtrace-api-v1.rs:34:18 (main)

0 comments on commit f36a5b9

Please sign in to comment.