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
Check for incompatible feature combinations #840
Comments
Yes, conditional enum variants are a big no-no. I remember this being a known-issue but it just hasn't been addressed yet so thanks for tracking this here! |
That's something else. Conditional enum variants will be solved with |
See this as a potential, likely good solution: https://github.com/LNP-BP/ln-types/pull/7/files#diff-f9353ba4d2ec2320d0f4b3ea4ed6409acebcab6567fd1c4dba72469a87228b5bR363 (whole + chunk) |
Fixed by #1026 |
That PR does something completely different though. |
Can you point to any features that, when enabled, break compilation? AFAIK since #1026 there are none. |
This is an audit issue so someone has to go and check. AFAIK nobody did yet. :) |
I checked before closing this. |
Issue is open still, should this be closed already? |
@apoelstra since you referenced a PR that is unrelated to this I don't think you understood the issue. Probably because the comment I referenced describes two separate things and Hopefully more clearly: for every For mandatory dependencies we only have to make sure |
You're right, I don't understand the issue. The issue that #1026 fixes is that adding features would literally break compilation by adding enum variants that people may have been matching on. By labelling these Separately, we shoud check that |
Yes it is a bug to have incompatible feature combinations because they can occur unexpectedly. |
I still don't understand in what sense there are "incompatible feature combinations" :( |
The situation is very obscure. Consider this code: Crate pub struct Error {
// fields
}
#[cfg(feature = "std")]
impl std::error::Error for Error {} Crate #[non_exhaustive]
pub enum Error {
#[cfg(feature = "foo")]
Foo(foo::Error),
IntegerOverflow,
}
#[cfg(feature = "std")]
impl std::error::Error for Error {
fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
match self {
#[cfg(feature = "foo")]
Error::Foo(foo) => Some(foo),
IntegerOverflow => None,
}
}
} Crate [features]
default = ["std"]
std = []
[dependencies]
foo = { version = "0.1", default-features = false, optional = true } Crate [dependencies]
foo = { version = "0.1", default-features = false } Binary crate - [dependencies]
bar = { version = "0.1", features = ["foo"] }
baz = "0.1" This produces compile error saying The solution (without bumping MSRV) is to have |
Thank you. I understand now. |
With the latest release of `rust-bitcoinconsensus` the `bicoinconsensus::Error` now implements `std::error::Error`. Correctly handle `bicoinconsensus::Error` by returning `Some(e)` and using `write_err` as is standard across the code base.
I randomly found one offender: |
I think this is actually the only error variant which is feature-gated at all. |
In my opinion, having been through all the error types a million times in the last six months this issue can be closed. |
Yeah, I've seen a bunch of code a number of times and AFAICT all features are additive. |
In rust-bitcoin/rust-secp256k1#408 (comment) I describe annoying issue with errors and features and I remember seeing features and conditional enum variants here, so we should check if they have the problem I describe there and fix it if we do.
The text was updated successfully, but these errors were encountered: