Closed shepmaster closed 1 year ago
Name | Link |
---|---|
Latest commit | b1e3e0972bf62d463369694c76e8f8689a00e8c9 |
Latest deploy log | https://app.netlify.com/sites/shepmaster-snafu/deploys/64f28db65e351a00080eff4b |
Deploy Preview | https://deploy-preview-396--shepmaster-snafu.netlify.app |
Preview on mobile | Toggle QR Code...Use your smartphone camera to open QR code link. |
To edit notification comments on pull requests, go to your Netlify site configuration.
cannot reliably identify whether the field
location
is indeed of type
That's correct. Proc macros only have knowledge of the literal source code, not any types or anything fancy.
Proc macros only have knowledge of the literal source code, not any types or anything fancy.
Seems thiserror
somehow handles this correctly, as the backtrace field can be named differently than backtrace
but if it has the std::backtrace::Backtrace
type it still will be recognized as backtrace (provide
method will be generated).
Firstly, I wanted to propose making Location
implicit by default, but after I found this issue :)
Proc macros only have knowledge of the literal source code, not any types or anything fancy.
Seems thiserror somehow handles this correctly
Can you please provide a code example demonstrating what you mean? I stated that the literal source code is all that the macro gets, but it seems like you are saying that is not true. If so, you should be able to write code where the error type has no literal words like "backtrace" and the automatic backtrace behavior still works:
use std::backtrace::Backtrace as Wubble;
#[derive(Error, Debug)]
pub struct MyError {
msg: String,
wubble: Wubble,
}
If you provide that, then I can go digging into thiserror to see how it works.
Yes, you're right. It will work if the field name differs from backtrace
but the field type still needs to contain Backtrace
. So, it indeed will not work for your example above.
It works for:
#[derive(Error, Debug)]
pub struct MyError {
msg: String,
wubble: std::backtrace::Backtrace,
}
or:
use std::backtrace::Backtrace as Backtrace;
#[derive(Error, Debug)]
pub struct MyError {
msg: String,
wubble: Backtrace,
}
Sorry for misleading.
Closes #339