Skip to content

Commit

Permalink
Merge pull request #627 from Thomasdezeeuw/check-features
Browse files Browse the repository at this point in the history
Check usage of max_level features
  • Loading branch information
KodrAus authored Apr 1, 2024
2 parents 28d734b + 710560e commit 405fdb4
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 2 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ jobs:
rustup default ${{ matrix.rust }}
- run: cargo test --verbose
- run: cargo test --verbose --no-default-features
- run: cargo test --verbose --all-features
- run: cargo test --verbose --features std,serde,sval,sval_ref,value-bag,kv,kv_std,kv_sval,kv_serde
- run: cargo test --verbose --features serde
- run: cargo test --verbose --features std
- run: cargo test --verbose --features kv
Expand Down Expand Up @@ -92,7 +92,7 @@ jobs:
rustup default stable
rustup component add rust-docs
- name: Run rustdoc
run: RUSTDOCFLAGS="-D warnings" cargo doc --verbose --all-features
run: RUSTDOCFLAGS="-D warnings" cargo doc --verbose --features std,serde,sval,sval_ref,value-bag,kv,kv_std,kv_sval,kv_serde

features:
name: Feature check
Expand Down
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 405fdb4

Please sign in to comment.