-
Notifications
You must be signed in to change notification settings - Fork 13.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Do not suggest using -Zmacro-backtrace
for builtin macros
#138379
Conversation
This PR modifies cc @jieyouxu |
91abd6e
to
70fc288
Compare
9a97100
to
6a7ddb6
Compare
This is similar to #106526 where you stated "I disagree with adding this kind of hacks to macro expansion infra, this PR does more harm than good." without clarification on whether the concern is with modifying |
This comment has been minimized.
This comment has been minimized.
6a7ddb6
to
aaff81e
Compare
Some changes occurred in src/tools/clippy cc @rust-lang/clippy |
This comment has been minimized.
This comment has been minimized.
@bors try @rust-timer queue |
This comment has been minimized.
This comment has been minimized.
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`
☀️ Try build successful - checks-actions |
This comment has been minimized.
This comment has been minimized.
Finished benchmarking commit (f3fd6c6): comparison URL. Overall result: no relevant changes - no action neededBenchmarking this pull request likely means that it is perf-sensitive, so we're automatically marking it as not fit for rolling up. While you can manually mark this PR as fit for rollup, we strongly recommend not doing so since this PR may lead to changes in compiler perf. @bors rollup=never Instruction countThis benchmark run did not return any relevant results for this metric. Max RSS (memory usage)Results (primary -1.6%)This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
CyclesThis benchmark run did not return any relevant results for this metric. Binary sizeResults (primary 0.1%, secondary 0.1%)This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
Bootstrap: 779.667s -> 779.217s (-0.06%) |
I'm fine with doing this for compiler-implemented macros with no actual source code, we already have a flag for those - I still disagree with doing this for standard library macros though. There can be some system for hiding the details, similar to |
aaff81e
to
197d2db
Compare
This comment has been minimized.
This comment has been minimized.
197d2db
to
c37a10c
Compare
The Miri subtree was changed cc @rust-lang/miri |
Made it so that we only hide the note when it comes from an intrinsic. |
For macros that are implemented on the compiler, we do *not* mention the `-Zmacro-backtrace` flag. This includes `derive`s and standard macros.
c37a10c
to
f0b8e13
Compare
@bors r+ |
☀️ Test successful - checks-actions |
Finished benchmarking commit (adea7cb): comparison URL. Overall result: no relevant changes - no action needed@rustbot label: -perf-regression Instruction countThis benchmark run did not return any relevant results for this metric. Max RSS (memory usage)This benchmark run did not return any relevant results for this metric. CyclesThis benchmark run did not return any relevant results for this metric. Binary sizeResults (primary 0.1%, secondary 0.1%)This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
Bootstrap: 772.05s -> 773.052s (0.13%) |
It seems like the PR description does not reflect the fact that the PR changed course before being landed? Or maybe I just entirely misunderstood. |
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 includesderive
s and standard macros likepanic!
andformat!
.This PR adds a field to every
Span
'sExpnData
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 withinvec![]
now doesn't mention the backtrace, but one could make the case that it should). Ideally, instead of carrying this information in theExpnData
we'd instead try to query theDefId
of the macro (that is already stored) to see if it is annotated in some way, but we do not have access to theTyCtxt
fromrustc_errors
.r? @petrochenkov