Skip to content

Commit

Permalink
Merge pull request #360 from Byron/no-default-features
Browse files Browse the repository at this point in the history
better error message when compiling with `--no-default-features` or `default-features = false`
  • Loading branch information
Byron committed Jul 6, 2023
2 parents f537522 + c9cf23f commit 74870ae
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 4 deletions.
7 changes: 7 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,19 @@ jobs:
- run: cargo test
- run: cargo test --features zlib
- run: cargo test --features zlib --no-default-features
- run: cargo test --features zlib-default --no-default-features
- run: cargo test --features zlib-ng-compat --no-default-features
if: matrix.build != 'mingw'
- run: cargo test --features zlib-ng --no-default-features
if: matrix.build != 'mingw'
- run: cargo test --features cloudflare_zlib --no-default-features
if: matrix.build != 'mingw'
- run: |
if ! cargo check --no-default-features 2>&1 | grep "You need to choose"; then
echo "expected message stating a zlib backend must be chosen"
exit 1
fi
if: matrix.build == 'stable'
rustfmt:
name: Rustfmt
Expand Down
5 changes: 3 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,14 @@ quickcheck = { version = "1.0", default-features = false }

[features]
default = ["rust_backend"]
any_zlib = [] # note: this is not a real user-facing feature
any_zlib = ["any_impl"] # note: this is not a real user-facing feature
any_impl = [] # note: this is not a real user-facing feature
zlib = ["any_zlib", "libz-sys"]
zlib-default = ["any_zlib", "libz-sys/default"]
zlib-ng-compat = ["zlib", "libz-sys/zlib-ng"]
zlib-ng = ["any_zlib", "libz-ng-sys"]
cloudflare_zlib = ["any_zlib", "cloudflare-zlib-sys"]
rust_backend = ["miniz_oxide"]
rust_backend = ["miniz_oxide", "any_impl"]
miniz-sys = ["rust_backend"] # For backwards compatibility

[package.metadata.docs.rs]
Expand Down
4 changes: 2 additions & 2 deletions src/ffi/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ mod c;
#[cfg(feature = "any_zlib")]
pub use self::c::*;

#[cfg(not(feature = "any_zlib"))]
#[cfg(all(not(feature = "any_zlib"), feature = "miniz_oxide"))]
mod rust;
#[cfg(not(feature = "any_zlib"))]
#[cfg(all(not(feature = "any_zlib"), feature = "miniz_oxide"))]
pub use self::rust::*;

impl std::fmt::Debug for ErrorMessage {
Expand Down
3 changes: 3 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@
#![cfg_attr(test, deny(warnings))]
#![cfg_attr(docsrs, feature(doc_auto_cfg))]

#[cfg(not(feature = "any_impl",))]
compile_error!("You need to choose a zlib backend");

pub use crate::crc::{Crc, CrcReader, CrcWriter};
pub use crate::gz::GzBuilder;
pub use crate::gz::GzHeader;
Expand Down

0 comments on commit 74870ae

Please sign in to comment.