You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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`
Copy file name to clipboardExpand all lines: src/tools/clippy/tests/ui/diverging_sub_expression.stderr
-2
Original file line number
Diff line number
Diff line change
@@ -36,8 +36,6 @@ error: sub-expression diverges
36
36
|
37
37
LL | _ => true || panic!("boo"),
38
38
| ^^^^^^^^^^^^^
39
-
|
40
-
= 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)
Copy file name to clipboardExpand all lines: src/tools/clippy/tests/ui/fallible_impl_from.stderr
-3
Original file line number
Diff line number
Diff line change
@@ -38,7 +38,6 @@ note: potential failure(s)
38
38
|
39
39
LL | panic!();
40
40
| ^^^^^^^^
41
-
= 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)
= 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)
= 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)
Copy file name to clipboardExpand all lines: src/tools/clippy/tests/ui/issue-7447.stderr
-3
Original file line number
Diff line number
Diff line change
@@ -6,15 +6,12 @@ LL | byte_view(panic!());
6
6
|
7
7
= note: `-D clippy::diverging-sub-expression` implied by `-D warnings`
8
8
= help: to override `-D warnings` add `#[allow(clippy::diverging_sub_expression)]`
9
-
= 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)
10
9
11
10
error: sub-expression diverges
12
11
--> tests/ui/issue-7447.rs:29:19
13
12
|
14
13
LL | group_entries(panic!());
15
14
| ^^^^^^^^
16
-
|
17
-
= 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)
0 commit comments