Skip to content

Commit

Permalink
feat: show clear compiler error when no backend is chosen. (rust-lang…
Browse files Browse the repository at this point in the history
  • Loading branch information
Byron committed Jul 5, 2023
1 parent 2684a56 commit c9cf23f
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 5 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,11 @@ jobs:
- 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
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 c9cf23f

Please sign in to comment.