-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Use #[track_caller] in const panic diagnostics. #87000
Conversation
It was already used for the message. This also uses it for the spans used for the error and backtrace.
Some changes occured to the CTFE / Miri engine cc @rust-lang/miri |
r? @jackh726 (rust-highfive has picked a reviewer for you, use r? to override) |
r? @oli-obk |
@bors r+ |
📌 Commit 0a4b53f has been approved by |
Rollup of 5 pull requests Successful merges: - rust-lang#86855 (Fix comments about unique borrows) - rust-lang#86881 (Inline implementation of lookup_line) - rust-lang#86937 (Change linked tracking issue for more_qualified_paths) - rust-lang#86994 (Update the comment on `lower_expr_try`) - rust-lang#87000 (Use #[track_caller] in const panic diagnostics.) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
.iter() | ||
.rev() | ||
.skip_while(|frame| frame.instance.def.requires_caller_location(*self.tcx)) | ||
{ |
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.
AFAIK this is also used for Miri error messages... do we really want those backtraces to skip frames? That sounds rather confusing. When we get a panic at runtime, with RUST_BACKTRACE
we also show the full trace, not just the non-caller-location frames, right?
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.
Even during CTFE, while this makes sense for panics, note that this logic is used for all CTFE errors. I am not sure if that's always what we want.
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.. right. we should limit this to panics
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.
Turns out this is also the source of some Miri panics in our diagnostics code which didn't expect pruned backtraces.
If we want this kind of pruning, we should not to it in the lowest-level generate_stacktrace
function.
.iter() | ||
.rev() | ||
.find(|frame| !frame.instance.def.requires_caller_location(*self.tcx)) | ||
.map_or(self.tcx.span, |f| f.current_span()) |
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 function at least used to be hot, we should have done a perf run... oh well.
…li-obk interpret: do not prune requires_caller_location stack frames quite so early rust-lang#87000 made the interpreter skip `caller_location` frames for its stacktraces and `cur_span`. However, those functions are used for much more than just panic reporting, and e.g. when Miri reports UB somewhere, it probably wants to point inside `caller_location` frames. (And if it did not, it would want to have its own logic to decide that, not be forced into it by the core interpreter engine.) This fixes some rare ICEs in Miri that say "we should never pop more than one frame at once". So let's remove all `caller_location` logic from the core interpreter, and instead move it to CTFE error reporting. This does not change user-visible behavior. That's the first commit. We might additionally want to change CTFE error reporting to treat panics differently from other errors: only prune `caller_location` frames for panics. The second commit does that. But honestly I am not sure if this is an improvement. r? `@oli-obk`
…li-obk interpret: do not prune requires_caller_location stack frames quite so early rust-lang#87000 made the interpreter skip `caller_location` frames for its stacktraces and `cur_span`. However, those functions are used for much more than just panic reporting, and e.g. when Miri reports UB somewhere, it probably wants to point inside `caller_location` frames. (And if it did not, it would want to have its own logic to decide that, not be forced into it by the core interpreter engine.) This fixes some rare ICEs in Miri that say "we should never pop more than one frame at once". So let's remove all `caller_location` logic from the core interpreter, and instead move it to CTFE error reporting. This does not change user-visible behavior. That's the first commit. We might additionally want to change CTFE error reporting to treat panics differently from other errors: only prune `caller_location` frames for panics. The second commit does that. But honestly I am not sure if this is an improvement. r? ``@oli-obk``
This change stops const panic diagnostics from reporting inside #[track_caller] functions by skipping over them.