Skip to content

Commit

Permalink
Check usage of max_level features
Browse files Browse the repository at this point in the history
With this change log will to fail to compile if two or more
(release_)max_level_* features are used.
  • Loading branch information
Thomasdezeeuw committed Mar 31, 2024
1 parent 28d734b commit 10ab472
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,45 @@
#![cfg_attr(rustbuild, feature(staged_api, rustc_private))]
#![cfg_attr(rustbuild, unstable(feature = "rustc_private", issue = "27812"))]

#[cfg(any(
all(feature = "max_level_off", feature = "max_level_error"),
all(feature = "max_level_off", feature = "max_level_warn"),
all(feature = "max_level_off", feature = "max_level_info"),
all(feature = "max_level_off", feature = "max_level_debug"),
all(feature = "max_level_off", feature = "max_level_trace"),
all(feature = "max_level_error", feature = "max_level_warn"),
all(feature = "max_level_error", feature = "max_level_info"),
all(feature = "max_level_error", feature = "max_level_debug"),
all(feature = "max_level_error", feature = "max_level_trace"),
all(feature = "max_level_warn", feature = "max_level_info"),
all(feature = "max_level_warn", feature = "max_level_debug"),
all(feature = "max_level_warn", feature = "max_level_trace"),
all(feature = "max_level_info", feature = "max_level_debug"),
all(feature = "max_level_info", feature = "max_level_trace"),
all(feature = "max_level_debug", feature = "max_level_trace"),
))]
compile_error!("multiple max_level_* features set");

#[rustfmt::skip]
#[cfg(any(
all(feature = "release_max_level_off", feature = "release_max_level_error"),
all(feature = "release_max_level_off", feature = "release_max_level_warn"),
all(feature = "release_max_level_off", feature = "release_max_level_info"),
all(feature = "release_max_level_off", feature = "release_max_level_debug"),
all(feature = "release_max_level_off", feature = "release_max_level_trace"),
all(feature = "release_max_level_error", feature = "release_max_level_warn"),
all(feature = "release_max_level_error", feature = "release_max_level_info"),
all(feature = "release_max_level_error", feature = "release_max_level_debug"),
all(feature = "release_max_level_error", feature = "release_max_level_trace"),
all(feature = "release_max_level_warn", feature = "release_max_level_info"),
all(feature = "release_max_level_warn", feature = "release_max_level_debug"),
all(feature = "release_max_level_warn", feature = "release_max_level_trace"),
all(feature = "release_max_level_info", feature = "release_max_level_debug"),
all(feature = "release_max_level_info", feature = "release_max_level_trace"),
all(feature = "release_max_level_debug", feature = "release_max_level_trace"),
))]
compile_error!("multiple release_max_level_* features set");

#[cfg(all(not(feature = "std"), not(test)))]
extern crate core as std;

Expand Down

0 comments on commit 10ab472

Please sign in to comment.