-
Notifications
You must be signed in to change notification settings - Fork 13.1k
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
Reverse the stack traces #38873
Comments
Coming from a JS - PHP background I was used to it because it's more relevant to get the latest error written at the top of the page displaying it. |
Perhaps worth a discussion on https://users.rust-lang.org (or internals) instead since I can see it being contentious? |
You may want to wait for #38165 to be merged before making your change, as it would be just adding a |
Note that this suggestion is all about improving the edit-compile-debug cycle, an explicit goal in the 2017 roadmap. Of course, whether or not it does improve it might be a personal thing. For me it absolutely does. Maybe an option to reverse it is a fair compromise, or at least a start? |
I'd like this too! It would also be nice if stack traces had pretty (terminal) colors, perhaps with an extension to RUST_BACKTRACE. Also: it would be useful if one could hide standard library sources from the stack trace. |
Triage: no changes here. |
Couple of thoughts: at this point, there’s no way we actually flip the default presentation. At the same time, we already allow controlling backtrace formatting via RUST_BACKTRACE env var. I think implementing a nightly-only RUST_BACKTRACE=“short,reversed” would be an immediate win which wouldn’t require too much bike shedding. |
A big improvement to the speed at which I can find the origin of a panic would be to reverse the order of the stack trace. At the moment the last line of the stack trace is always
main
. This means the stack trace is written deep->shallow, or in reverse(!) chronological order:What you are generally looking for is the place that caused the panic (e.g. the line with an
assert!
orpanic!
on it), and so I think it would make sense to have that line last so that it is easy to find. This is particularly important when the call stack is deep and it fills your terminal. Here is a more in-depth argument for this.So my suggestion is: reverse the stack trace to print the stack frames in chronological order, shallow->deep, with
main
on the top and the stack frame with the panic at the end:I realize this can become quite the bikeshedding religious war, and maybe this has been discussed before – if so, I apologize. Still, until the blog post above brought it up I didn't realize that most languages – including Rust – was doing it wrong, and that there was a better way. In C++ I switched the order I print stack traces about a year ago, and since then it has saved me a lot of scrolling.
EDIT: I've created a forum thread about this here: https://users.rust-lang.org/t/reverse-stack-trace-order/8786
The text was updated successfully, but these errors were encountered: