From b3d166839c6f46b194a6e53dbed38c5a83cb6f65 Mon Sep 17 00:00:00 2001 From: Jakub Jirutka Date: Fri, 5 Jan 2024 01:26:40 +0100 Subject: [PATCH] feat: fail build if both tls-native and tls-rustls are enabled --- Cargo.toml | 2 +- README.md | 8 ++++---- src/lib.rs | 3 +++ 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index e2a197419..4f9fe84ca 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -39,7 +39,7 @@ default = ["tls-rustls"] cli = ["merge", "clap"] merge = ["dep:merge"] clap = ["dep:clap"] -# The tls-* features should be treated as mutually exclusive. +# tls-native and tls-rustls are mutually exclusive. tls-native = ["reqwest/native-tls"] tls-rustls = ["reqwest/rustls-tls-native-roots"] diff --git a/README.md b/README.md index ba279cfb7..c39bd6f7c 100644 --- a/README.md +++ b/README.md @@ -55,11 +55,11 @@ This crate exposes a few features for controlling dependency usage: - **clap** - Enables a dependency on the `clap` crate and enables parsing from the commandline. *This feature is disabled by default*. - **tls-native** - Builds with native TLS support (i.e. link against system TLS - library). This feature should be treated as mutually exclusive with - `tls-rustls`. *This features is disabled by default*. + library). *This feature is mutually exclusive with `tls-rustls` and it is + disabled by default*. - **tls-rustls** - Builds with Rustls support (i.e. with bundled TLS library). - This feature should be treated as mutually exclusive with `tls-native`. *This - feature is enabled by default*. + *This feature is mutually exclusive with `tls-native` and it is enabled by + default*. ## Examples diff --git a/src/lib.rs b/src/lib.rs index 04bda03e8..2f29097ca 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -139,6 +139,9 @@ This crate exposes a few features for controlling dependency usage. #![allow(rustdoc::private_intra_doc_links)] #![allow(clippy::needless_raw_string_hashes)] +#[cfg(all(feature = "tls-native", feature = "tls-rustls "))] +compile_error!("features \"tls-native\" and \"tls-rustls \" cannot be enabled at the same time. Please disable one of them."); + pub(crate) mod archiver; pub(crate) mod backend; pub(crate) mod blob;