-
-
Notifications
You must be signed in to change notification settings - Fork 9
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
derive: fix compilation error if user define its own Result type #20
derive: fix compilation error if user define its own Result type #20
Conversation
dxr_derive/src/lib.rs
Outdated
@@ -145,7 +145,7 @@ pub fn try_from_value(input: TokenStream) -> TokenStream { | |||
|
|||
let impl_block = quote! { | |||
impl #impl_generics #dxr::TryFromValue for #name #ty_generics #where_clause { | |||
fn try_from_value(value: &#dxr::Value) -> Result<#name #ty_generics, #dxr::DxrError> { | |||
fn try_from_value(value: &#dxr::Value) -> std::result::Result<#name #ty_generics, #dxr::DxrError> { |
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.
Can you replace this with ::std::result::Result
, similar to other std
imports?
dxr_derive/src/lib.rs
Outdated
@@ -258,7 +258,7 @@ pub fn try_to_value(input: TokenStream) -> TokenStream { | |||
|
|||
let impl_block = quote! { | |||
impl #impl_generics #dxr::TryToValue for #name #ty_generics #where_clause { | |||
fn try_to_value(&self) -> Result<#dxr::Value, #dxr::DxrError> { | |||
fn try_to_value(&self) -> std::result::Result<#dxr::Value, #dxr::DxrError> { |
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.
Same thing applies here.
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.
Thank you, this looks mostly good to me, with two minor issues.
(Imagine somebody redefining std
, it would cause the same problem as the custom Result
.)
48714b2
to
c4d2738
Compare
Great, thanks! Let's see what the CI says. |
I updated the PR with your wise remarks.
This is a terrifying thought 😱. |
It seems that the nightly jobs is failing to the |
Yeah, the failure with |
c4d2738
to
ff9a453
Compare
Awesome. Thank you for the contribution! |
Do you need a new release in the v0.6 branch with this fix? Or would it be OK if this just ends up in 0.7.0? |
If it's not too much work I would be happy to have a release with the fix but I can implement a workaround in my code and can wait for the 0.7.0 version. |
I'm working on some refactors for 0.7.0 still, so I'll cherry-pick your change onto the v0.6 release series and publish a new version. |
When using the
TryFromValue
andTryToValue
macros in a file where a customResult
is defined (in my casetype Result<T> = std::result::Result<T, Box<dyn Error + Send + Sync>>;
) the macro doesn't work anymore and create a compilation error.The Result seems to be common pattern and I think it should not break the macrso (https://doc.rust-lang.org/rust-by-example/error/result/result_alias.html )