-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Track where diagnostics were created. #103217
Conversation
Some changes occurred in src/tools/clippy cc @rust-lang/clippy Some changes occurred in src/tools/rustfmt cc @rust-lang/rustfmt |
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @eholk (or someone else) soon. Please see the contribution instructions for more information. |
@@ -1211,6 +1211,7 @@ pub fn report_ice(info: &panic::PanicInfo<'_>, bug_report_url: &str) { | |||
false, | |||
None, | |||
false, | |||
false, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is getting to be a lot of arguments, maybe add a Config
struct? Doesn't need to block this PR though
@@ -691,6 +691,7 @@ fn check_code(cx: &LateContext<'_>, text: &str, edition: Edition, span: Span) { | |||
false, | |||
None, | |||
false, | |||
false, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same for clippy and rustfmt.
This comment has been minimized.
This comment has been minimized.
Not sure about |
fallback_bundle, | ||
None, | ||
false, | ||
false, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think if you don't set this for JSON output, it won't show up when using cargo.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure what you mean with that. Afaik most code that calls this function doesn't have the sessions options available to it (because it's creating it). So i'm not sure what to do here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, this is in early_error
, I misread. Ok, seems fine to skip for now. I think it shouldn't be too hard to add it though, nearly every place that calls this has access to Options
and those that don't can still call matches.opt_get("track-diagnostics")
before calling the error code.
|
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
I'm starting to look over this PR. One general question, is adding |
I think this looks pretty good! The main thing left is to make sure all of @jyn514's comments get addressed (it looks like the hardcoding changes for clippy and rustfmt are the main ones). |
When would this be used rather than |
@camsteffen this can be used in a compiler that has debug symbols disabled, and without reading through 200 lines of stack trace from rustc_query_impl. |
cc @davidtwco, @compiler-errors, @JohnTitor, @estebank, @TaKO8Ki |
@jyn514 have I addressed all of your comments? I sort of lost track because I bit off small pieces here and there over the last week and I'm not totally sure I understood everything completely.
That could be a bit annoying if it happens but I don't think it's an issue. Most of the functions that have it now just call |
Hmm, the only one I had left was #103217 (comment), but it looks like clippy is emitting -Ztrack-diagnostics notes even though you always pass in false? Not sure what's going on there. |
It looks like clippy uses the compiler's machinery for that, and just provides a callback to add its configuration? The change I made in clippy driver just passes in false if an ice is reported. |
Ok, great. I'm still not sure rustfmt is handling the option properly, but we can always add it later if someone complains.
@bors r=eholk rollup=iffy |
☀️ Test successful - checks-actions |
Finished benchmarking commit (11ebe65): comparison URL. Overall result: ❌ regressions - ACTION NEEDEDNext Steps: If you can justify the regressions found in this perf run, please indicate this with @rustbot label: +perf-regression Instruction countThis is a highly reliable metric that was used to determine the overall result at the top of this comment.
Max RSS (memory usage)ResultsThis 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.
CyclesResultsThis 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.
|
I think |
I think the likelihood that this is noise is pretty high as you can see from the end of this graph. I think we should assume noise in this case. If it's true regression it's small enough to not be a big deal. @rustbot label: +perf-regression-triaged |
Possibly easier to chat in Zulip, but could you help me understand what you mean by this @jyn514? Admit I've only done a cursory pass through this PR but it's not clear to me |
@calebcartwright I mean I'm not sure that running |
Gotcha. I can't conjure up a persona that I think would need that right now, so I'm happy to punt this to a future caleb on the off chance anyone ever does come up with a need |
Track where diagnostics were created. This implements the `-Ztrack-diagnostics` flag, which uses `#[track_caller]` to track where diagnostics are created. It is meant as a debugging tool much like `-Ztreat-err-as-bug`. For example, the following code... ```rust struct A; struct B; fn main(){ let _: A = B; } ``` ...now emits the following error message: ``` error[E0308]: mismatched types --> src\main.rs:5:16 | 5 | let _: A = B; | - ^ expected struct `A`, found struct `B` | | | expected due to this -Ztrack-diagnostics: created at compiler\rustc_infer\src\infer\error_reporting\mod.rs:2275:31 ```
Track where diagnostics were created. This implements the `-Ztrack-diagnostics` flag, which uses `#[track_caller]` to track where diagnostics are created. It is meant as a debugging tool much like `-Ztreat-err-as-bug`. For example, the following code... ```rust struct A; struct B; fn main(){ let _: A = B; } ``` ...now emits the following error message: ``` error[E0308]: mismatched types --> src\main.rs:5:16 | 5 | let _: A = B; | - ^ expected struct `A`, found struct `B` | | | expected due to this -Ztrack-diagnostics: created at compiler\rustc_infer\src\infer\error_reporting\mod.rs:2275:31 ```
Track where diagnostics were created. This implements the `-Ztrack-diagnostics` flag, which uses `#[track_caller]` to track where diagnostics are created. It is meant as a debugging tool much like `-Ztreat-err-as-bug`. For example, the following code... ```rust struct A; struct B; fn main(){ let _: A = B; } ``` ...now emits the following error message: ``` error[E0308]: mismatched types --> src\main.rs:5:16 | 5 | let _: A = B; | - ^ expected struct `A`, found struct `B` | | | expected due to this -Ztrack-diagnostics: created at compiler\rustc_infer\src\infer\error_reporting\mod.rs:2275:31 ```
This implements the
-Ztrack-diagnostics
flag, which uses#[track_caller]
to track where diagnostics are created. It is meant as a debugging tool much like-Ztreat-err-as-bug
.For example, the following code...
...now emits the following error message: