cargo-hack icon indicating copy to clipboard operation
cargo-hack copied to clipboard

Provide a way to allow (or check) to fail a particular combination of features

Open taiki-e opened this issue 4 years ago • 1 comments

usecases:

  • https://github.com/rust-lang/regex/blob/d6bc7a4c3b58e1d618024aaededa722df32fa6e8/src/lib.rs#L613
  • https://github.com/rust-lang/futures-rs/blob/3601bb76708ea4bcc14c3491237abc33b685ba0b/futures/src/lib.rs#L100
  • https://doc.rust-lang.org/cargo/reference/features.html#mutually-exclusive-features

taiki-e avatar Feb 27 '21 03:02 taiki-e

Another use case, roughly:

cfg_if! {
    if #[cfg(feature = "unstable")] {
        // do something unstable
    } else if #[cfg(feature = "polyfill")] {
        // do something polyfilled
    } else {
        compile_error!("requires the `unstable` or `polyfill` feature");
    }
}

This is useful when the polyfill feature is a dependency. (Example: std::lazy and once_cell.)

Though this is achievable with

cargo hack check --feature-powerset --features unstable
cargo hack check --feature-powerset --features polyfill

CAD97 avatar Apr 01 '22 17:04 CAD97

Either this or #182 would be quite helpful.

tamird avatar Jul 14 '23 02:07 tamird

As already said in #182, I would accept a PR to implement #182.

taiki-e avatar Jul 14 '23 16:07 taiki-e

Closing in favor of #182.

taiki-e avatar Sep 01 '23 18:09 taiki-e