Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit f3fd6c6

Browse files
committedMar 12, 2025
Auto merge of #138379 - estebank:macro-backtrace-note, r=<try>
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 0998d40 + aaff81e commit f3fd6c6

File tree

283 files changed

+40
-713
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

283 files changed

+40
-713
lines changed
 

‎tests/ui/alloc-error/alloc-error-handler-bad-signature-1.stderr

-2
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ LL | fn oom(
1818
| ^^^
1919
LL | info: &Layout,
2020
| -------------
21-
= note: this error originates in the attribute macro `alloc_error_handler` (in Nightly builds, run with -Z macro-backtrace for more info)
2221

2322
error[E0308]: mismatched types
2423
--> $DIR/alloc-error-handler-bad-signature-1.rs:10:1
@@ -35,7 +34,6 @@ LL | | }
3534
|
3635
= note: expected type `!`
3736
found unit type `()`
38-
= note: this error originates in the attribute macro `alloc_error_handler` (in Nightly builds, run with -Z macro-backtrace for more info)
3937

4038
error: aborting due to 2 previous errors
4139

‎tests/ui/alloc-error/alloc-error-handler-bad-signature-2.stderr

-2
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ LL | fn oom(
2626
| ^^^
2727
LL | info: Layout,
2828
| ------------
29-
= note: this error originates in the attribute macro `alloc_error_handler` (in Nightly builds, run with -Z macro-backtrace for more info)
3029

3130
error[E0308]: mismatched types
3231
--> $DIR/alloc-error-handler-bad-signature-2.rs:10:1
@@ -43,7 +42,6 @@ LL | | }
4342
|
4443
= note: expected type `!`
4544
found unit type `()`
46-
= note: this error originates in the attribute macro `alloc_error_handler` (in Nightly builds, run with -Z macro-backtrace for more info)
4745

4846
error: aborting due to 2 previous errors
4947

‎tests/ui/alloc-error/alloc-error-handler-bad-signature-3.stderr

-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ note: function defined here
1414
|
1515
LL | fn oom() -> ! {
1616
| ^^^
17-
= note: this error originates in the attribute macro `alloc_error_handler` (in Nightly builds, run with -Z macro-backtrace for more info)
1817

1918
error: aborting due to 1 previous error
2019

There was a problem loading the remainder of the diff.

0 commit comments

Comments
 (0)
Failed to load comments.