Skip to content

Commit

Permalink
debuginfo: Stabilize -Z debug-macros, -Z collapse-macro-debuginfo
Browse files Browse the repository at this point in the history
… 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.
  • Loading branch information
petrochenkov committed Apr 25, 2024
1 parent 664e7fa commit b57428c
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 b57428c

Please sign in to comment.