refactor: Eliminate deprecation warning when --all-features implicitly enables the deprecated feature

This commit is contained in:
Chris Hennick 2024-05-15 17:13:20 -07:00
parent fbf111ef97
commit 1cb0e1b3b7
No known key found for this signature in database
GPG key ID: DA47AABA4961C509
3 changed files with 13 additions and 11 deletions

View file

@ -63,6 +63,7 @@ tempdir = "0.3.7"
aes-crypto = ["aes", "constant_time_eq", "hmac", "pbkdf2", "sha1", "rand", "zeroize"]
chrono = ["chrono/default"]
_deflate-any = []
_all-features = [] # Detect when --all-features is used
deflate = ["flate2/rust_backend", "_deflate-any"]
# DEPRECATED: previously enabled `flate2/miniz_oxide` which is equivalent to `flate2/rust_backend`

View file

@ -25,8 +25,8 @@ struct Args {
enum CompressionMethod {
Stored,
Deflated,
DeflatedMiniz,
DeflatedZlib,
DeflatedZlibNg,
Bzip2,
Zstd,
}
@ -50,15 +50,6 @@ fn real_main() -> i32 {
#[cfg(feature = "deflate")]
zip::CompressionMethod::Deflated
}
CompressionMethod::DeflatedMiniz => {
#[cfg(not(feature = "deflate-miniz"))]
{
println!("The `deflate-miniz` feature is not enabled");
return 1;
}
#[cfg(feature = "deflate-miniz")]
zip::CompressionMethod::Deflated
}
CompressionMethod::DeflatedZlib => {
#[cfg(not(feature = "deflate-zlib"))]
{
@ -68,6 +59,15 @@ fn real_main() -> i32 {
#[cfg(feature = "deflate-zlib")]
zip::CompressionMethod::Deflated
}
CompressionMethod::DeflatedZlibNg => {
#[cfg(not(feature = "deflate-zlib-ng"))]
{
println!("The `deflate-zlib-ng` feature is not enabled");
return 1;
}
#[cfg(feature = "deflate-zlib-ng")]
zip::CompressionMethod::Deflated
}
CompressionMethod::Bzip2 => {
#[cfg(not(feature = "bzip2"))]
{

View file

@ -1,7 +1,8 @@
use std::env::var;
fn main() {
if var("CARGO_FEATURE_DEFLATE_MINIZ").is_ok() {
if var("CARGO_FEATURE_DEFLATE_MINIZ").is_ok()
&& var("CARGO_FEATURE__ALL_FEATURES").is_err() {
println!("cargo:warning=Feature `deflate-miniz` is deprecated; replace it with `deflate`");
}
}