Skip to content

Commit db870ea

Browse files
committed
Auto merge of rust-lang#75194 - Aaron1011:feature/macro-backtrace-numbers, r=eddyb
Show backtrace numbers in backtrace whenever more than one is involved Previously, we only displayed 'frame' numbers in a macro backtrace when more than two frames were involved. This commit should help make backtrace more readable, since these kinds of messages can quickly get confusing.
2 parents ec9d524 + f9f8923 commit db870ea

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

src/librustc_errors/emitter.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,7 @@ pub trait Emitter {
362362
format!(
363363
"in this expansion of `{}`{}",
364364
trace.kind.descr(),
365-
if macro_backtrace.len() > 2 {
365+
if macro_backtrace.len() > 1 {
366366
// if macro_backtrace.len() == 1 it'll be
367367
// pointed at by "in this macro invocation"
368368
format!(" (#{})", i + 1)
@@ -393,7 +393,7 @@ pub trait Emitter {
393393
trace.call_site,
394394
format!(
395395
"in this macro invocation{}",
396-
if macro_backtrace.len() > 2 && always_backtrace {
396+
if macro_backtrace.len() > 1 && always_backtrace {
397397
// only specify order when the macro
398398
// backtrace is multiple levels deep
399399
format!(" (#{})", i + 1)

src/test/ui/macro_backtrace/main.-Zmacro-backtrace.stderr

+4-4
Original file line numberDiff line numberDiff line change
@@ -17,20 +17,20 @@ LL | / macro_rules! pong {
1717
LL | | () => { syntax error };
1818
| | ^^^^^ expected one of 8 possible tokens
1919
LL | | }
20-
| |__- in this expansion of `pong!`
20+
| |__- in this expansion of `pong!` (#2)
2121
...
2222
LL | ping!();
23-
| -------- in this macro invocation
23+
| -------- in this macro invocation (#1)
2424
|
2525
::: $DIR/auxiliary/ping.rs:5:1
2626
|
2727
LL | / macro_rules! ping {
2828
LL | | () => {
2929
LL | | pong!();
30-
| | -------- in this macro invocation
30+
| | -------- in this macro invocation (#2)
3131
LL | | }
3232
LL | | }
33-
| |_- in this expansion of `ping!`
33+
| |_- in this expansion of `ping!` (#1)
3434

3535
error: expected one of `!`, `.`, `::`, `;`, `?`, `{`, `}`, or an operator, found `error`
3636
--> $DIR/main.rs:10:20

0 commit comments

Comments
 (0)