Skip to content

Commit 031a5ad

Browse files
committed
Auto merge of #138379 - estebank:macro-backtrace-note, r=petrochenkov
Do not suggest using `-Zmacro-backtrace` for builtin macros For macros that are implemented on the compiler, or that are annotated with `rustc_diagnostic_item`, which have arbitrary implementations from the point of view of the user and might as well be intrinsics, we do *not* mention the `-Zmacro-backtrace` flag. This includes `derive`s and standard macros like `panic!` and `format!`. This PR adds a field to every `Span`'s `ExpnData` stating whether it comes from a builtin macro. This is determined by the macro being annotated with either `#[rustc_builtin_macro]` or `#[rustc_diagnostic_item]`. An alternative to using these attributes that already exist for other uses would be to introduce another attribute like `#[rustc_no_backtrace]` to have finer control on which macros are affected (for example, an error within `vec![]` now doesn't mention the backtrace, but one could make the case that it should). Ideally, instead of carrying this information in the `ExpnData` we'd instead try to query the `DefId` of the macro (that is already stored) to see if it is annotated in some way, but we do not have access to the `TyCtxt` from `rustc_errors`. r? `@petrochenkov`
2 parents ca04f99 + c334c5a commit 031a5ad

7 files changed

+0
-8
lines changed

tests/fail/alloc/alloc_error_handler_custom.stderr

-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ note: inside `miri_start`
2121
|
2222
LL | handle_alloc_error(Layout::for_value(&0));
2323
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
24-
= note: this error originates in the attribute macro `alloc_error_handler` (in Nightly builds, run with -Z macro-backtrace for more info)
2524

2625
error: aborting due to 1 previous error
2726

tests/fail/erroneous_const.stderr

-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@ error[E0080]: evaluation of `PrintName::<i32>::VOID` failed
33
|
44
LL | const VOID: ! = panic!();
55
| ^^^^^^^^ evaluation panicked: explicit panic
6-
|
7-
= note: this error originates in the macro `$crate::panic::panic_2021` which comes from the expansion of the macro `panic` (in Nightly builds, run with -Z macro-backtrace for more info)
86

97
note: erroneous constant encountered
108
--> tests/fail/erroneous_const.rs:LL:CC

tests/fail/panic/no_std.stderr

-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ note: inside `miri_start`
1313
|
1414
LL | panic!("blarg I am dead")
1515
| ^^^^^^^^^^^^^^^^^^^^^^^^^
16-
= note: this error originates in the macro `$crate::panic::panic_2021` which comes from the expansion of the macro `panic` (in Nightly builds, run with -Z macro-backtrace for more info)
1716

1817
note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace
1918

tests/fail/panic/panic_abort1.stderr

-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ note: inside `main`
2222
|
2323
LL | std::panic!("panicking from libstd");
2424
| ^
25-
= note: this error originates in the macro `$crate::panic::panic_2021` which comes from the expansion of the macro `std::panic` (in Nightly builds, run with -Z macro-backtrace for more info)
2625

2726
note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace
2827

tests/fail/panic/panic_abort2.stderr

-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ note: inside `main`
2222
|
2323
LL | std::panic!("{}-panicking from libstd", 42);
2424
| ^
25-
= note: this error originates in the macro `$crate::panic::panic_2021` which comes from the expansion of the macro `std::panic` (in Nightly builds, run with -Z macro-backtrace for more info)
2625

2726
note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace
2827

tests/fail/panic/panic_abort3.stderr

-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ note: inside `main`
2222
|
2323
LL | core::panic!("panicking from libcore");
2424
| ^
25-
= note: this error originates in the macro `$crate::panic::panic_2021` which comes from the expansion of the macro `core::panic` (in Nightly builds, run with -Z macro-backtrace for more info)
2625

2726
note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace
2827

tests/fail/panic/panic_abort4.stderr

-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ note: inside `main`
2222
|
2323
LL | core::panic!("{}-panicking from libcore", 42);
2424
| ^
25-
= note: this error originates in the macro `$crate::panic::panic_2021` which comes from the expansion of the macro `core::panic` (in Nightly builds, run with -Z macro-backtrace for more info)
2625

2726
note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace
2827

0 commit comments

Comments
 (0)