-
Notifications
You must be signed in to change notification settings - Fork 270
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 core::error
instead of std::error
to increase compatibility in no_std
environments
#597
base: master
Are you sure you want to change the base?
Conversation
So, as written this is definitely going to fail CI because the I can understand the desire to have this, but adding a feature flag that requires a nightly compiler is a tough pill for us to swallow ... it means that we have to explicitly list all the non-nightly features rather than using |
Thank you for the quick and open feedback. I understand your concerns regarding
I am more than happy to rewrite the feature gate like this: -#![cfg_attr(feature = "core-error", feature(error_in_core))]
+#![cfg_attr(all(feature = "core-error", not(feature = "std")), feature(error_in_core))] So this would only be used if explicitly enabled without the The |
This is a cool idea, but unfortunately it would then break additivity of features -- meaning that if somebody included |
@@ -35,6 +35,7 @@ global-context = ["std"] | |||
# if you are doing a no-std build, then this feature does nothing | |||
# and is not necessary.) | |||
global-context-less-secure = ["global-context"] | |||
core-error = [] |
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.
If we're going to use this, I'd want the feature to be named unstable-nightly-core-error
and document the limitations.
Error::InvalidParityValue(error) => Some(error), | ||
} | ||
} | ||
} |
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.
Why duplicate this? You could just modify the condition above. Oh, brainfart, it's obvious. You could just cfg use std::error::Error as StdError
/use core::error::Error as StdError
and change impl to say StdError
.
I don't think so. There's whole new provider API that's being discussed and I'm not sure @apoelstra I'm not sure it'd break additivity since if the feature is enabled presumably the trait in |
Thanks for the feedback @Kixunil. Just for clarification: are you willing to merge it if the requested changes has been made? |
I wouldn't be opposed to it but it's not my call. Once it stabilizes we can conditionally enable it from build script as we do for other things, which would be nicer. |
I wonder if we can conditionally enable it now somehow ... in that case I'd be fine with it (assuming also that we did the |
In principle we could detect nightly but we shouldn't because it'll break if they decide to change the API or something. Opting into instability should be explicit. (That's why I asked to rename the feature.) |
@Kixunil could we do both (require a feature, but disable/override it on non-nightly rather than running into compiler errors)? |
If someone actually depended on it they'd get error much later in compilation which is not nice. I'd prefer we just avoid using |
There is a
thiserror
fork calledthiserror-core
which allows it to be used inno_std
environments.I added a new feature flag
core-error
which enables the currently not yet stabilizederror_in_core
feature.This enables the
thiserror-core
crate to work fine.