-
Notifications
You must be signed in to change notification settings - Fork 389
Improve information sharing across SB diagnostics #2454
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
Conversation
I was reminded that this can probably be used to produce better tag-tracking diagnostics. Might implement that later... |
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 a big fan of the more detailed errors! However, I hope we can find a way to implement that that does not reply on passing information implicitly through global state...
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.
Yes, much better. :)
FYI this is now about a 10% perf regression on all benchmarks, on account of the I don't know why that function is so expensive, but the disassembly is massive. |
1590eea
to
8ccb139
Compare
Oh wow. Okay then let's do that yet, instead please open an issue to track further investigation. |
8ccb139
to
b47c1f8
Compare
Fresh brain in the morning. I realized that I was pointlessly checking for diff --git a/src/helpers.rs b/src/helpers.rs
index e3142caa..bf536c24 100644
--- a/src/helpers.rs
+++ b/src/helpers.rs
@@ -923,6 +923,8 @@ impl<'a, 'mir: 'a, 'tcx: 'a + 'mir> CurrentSpan<'a, 'mir, 'tcx> {
.unwrap_or(rustc_span::DUMMY_SP)
}
+ // Find the position of the inner-most frame which is part of the crate being
+ // compiled/executed, part of the Cargo workspace, and is also not #[track_caller].
fn current_span_index(tcx: TyCtxt<'_>, machine: &Evaluator<'_, '_>) -> usize {
machine
.threads
@@ -930,11 +932,11 @@ impl<'a, 'mir: 'a, 'tcx: 'a + 'mir> CurrentSpan<'a, 'mir, 'tcx> {
.iter()
.enumerate()
.rev()
- // Skip #[track_caller] frames
- .filter(|(_, frame)| !frame.instance.def.requires_caller_location(tcx))
.find_map(|(idx, frame)| {
let def_id = frame.instance.def_id();
- if def_id.is_local() || machine.local_crates.contains(&def_id.krate) {
+ if (def_id.is_local() || machine.local_crates.contains(&def_id.krate))
+ && !frame.instance.def.requires_caller_location(tcx)
+ {
Some(idx)
} else {
None This is now on average perf-neutral, with some small improvements and regressions. |
(Please don't rebase+amend unless there are conflicts. Rebasing destroys being able to get decent diffs from github for what you changed between revisions.) |
I was wondering how you were dealing with this before, sorry about that 🙃 |
For big PRs like this, ideally just keep adding new commits, then even after a rebase it's easy to see what is new. Squashing is an optimization that can happen when we are done. :) |
☔ The latest upstream changes (presumably #2488) made this pull request unmergeable. Please resolve the merge conflicts. |
@rustbot author |
Previous Stacked Borrows diagnostics were missing a lot of information about the state of the interpreter, and it was difficult to add additional state because it was threaded through all the intervening function signatures. This change factors a lot of the arguments which used to be passed individually to many stacked borrows functions into a single `DiagnosticCx`, which is built in `Stacks::for_each`, and since it wraps a handle to `AllocHistory`, we can now handle more nuanced things like heterogeneous borrow of `!Freeze` types.
f8d8ab8
to
0e5a53d
Compare
I took the liberty to take care of the last nit, so that the nicer diagnostics can be part of the next Miri update. :) @bors r+ |
Improve information sharing across SB diagnostics Previous Stacked Borrows diagnostics were missing a lot of information about the state of the interpreter, and it was difficult to add additional state because it was threaded through all the intervening function signatures. This change factors a lot of the arguments which used to be passed individually to many stacked borrows functions into a single `DiagnosticCx`, which is built in `Stacks::for_each`, and since it wraps a handle to `AllocHistory`, we can now handle more nuanced things like heterogeneous borrow of `!Freeze` types.
💔 Test failed - checks-actions |
ba9d8d2
to
7397c8e
Compare
@bors r+ |
☀️ Test successful - checks-actions |
Thanks for taking care of this! |
Previous Stacked Borrows diagnostics were missing a lot of information about the state of the interpreter, and it was difficult to add additional state because it was threaded through all the intervening function signatures.
This change factors a lot of the arguments which used to be passed individually to many stacked borrows functions into a single
DiagnosticCx
, which is built inStacks::for_each
, and since it wraps a handle toAllocHistory
, we can now handle more nuanced things like heterogeneous borrow of!Freeze
types.