-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
transparent attribute #1744
Comments
I'm curious what impact this would have on debugging. I can see how this would be useful, but I can also imagine wanting to know what the whole stack trace is. Is that what you mean by
|
To avoid confusion, I'd suggest that we shouldn't hide such functions by default; we should just de-emphasize them, and emphasize the top non-transparent item in the stack. Otherwise, when people learning Rust see a panic, the stack traces might have a lot less didactic value for them. |
@joshtriplett This is a good point... Another idea would be to de-emphasize code in external crates by default. This idea is orthogonal to the original proposal... |
One of the tools I use at work displays Javascript call stacks with the "uninteresting parts" collapsed into lines like "10 frames omitted from [module name]". Is that the sort of thing you have in mind when you say "deemphasizing"? |
This is what I imagined... Take this stack trace:
We might want to "de-emphasize" the stack trace entries in
|
I've implemented something like this once for cleanup of exception stack traces (in a custom error reporting solution for PHP), and I've found that "transparent" is not quite what I wanted. The problem is that errors fall into two separate categories:
So in case (1) you want the function to be transparent (so the user sees place where they call it and args they pass in), but in (2) you specifically don't want it (as it'd hide the actual error and incorrectly blame the user). |
How would line numbers in the reported error message work? Right now, |
If the panic is in a library you didn't write, the line numbers will be
meaningless anyway. Instead, you would look at the error message and try to
find the offensive code in your own work, right ?
…On Jul 12, 2017 8:24 AM, "Jake Goulding" ***@***.***> wrote:
How would line numbers in the reported error message work? Right now,
panic! uses the line!() and file() macros to grab these. If the panic
message says one file (the real location) and the stack trace doesn't
include that, it would be very confusing.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#1744 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AIazwJRQEYCmhvI9PaotM7TK2EV-FFm4ks5sNLrfgaJpZM4J4V0x>
.
|
Closing in favor of rust-lang/rust#47809. |
#[transparent]
on functions and types, basically means never presented to the user (modulo a flag to turn this off). E.g., would be on theunwrap
implementation methods so that that a stack trace doesn't display the noise of the panic and unwrap implementation as the top of the stack trace.Use on types is to avoid telling the user about things like
UnsafeCell
which are usually just noise in error messages for users, they should be transparent wrappers.Used by std libs in Swift.
cc @gankro
The text was updated successfully, but these errors were encountered: