Skip to content

Commit

Permalink
Fix validation for api-* mutual exclusivity
Browse files Browse the repository at this point in the history
  • Loading branch information
Bromeon committed Jul 22, 2024
1 parent f601eb6 commit 3261dea
Showing 1 changed file with 19 additions and 10 deletions.
29 changes: 19 additions & 10 deletions godot/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,18 +151,27 @@ compile_error!("The feature `double-precision` currently requires `api-custom` d
#[cfg(feature = "custom-godot")]
__deprecated::emit_deprecated_warning!(feature_custom_godot);

#[rustfmt::skip]
const fn _validate_features() {
let mut count = 0;

if cfg!(feature = "api-4-0") {
count += 1;
}
if cfg!(feature = "api-4-1") {
count += 1;
}
if cfg!(feature = "api-custom") {
count += 1;
}
if cfg!(feature = "api-custom") { count += 1; }

// [version-sync] [[
// [line] \tif cfg!(feature = "api-$kebabVersion") { count += 1; }
if cfg!(feature = "api-4-0") { count += 1; }
if cfg!(feature = "api-4-0-1") { count += 1; }
if cfg!(feature = "api-4-0-2") { count += 1; }
if cfg!(feature = "api-4-0-3") { count += 1; }
if cfg!(feature = "api-4-0-4") { count += 1; }
if cfg!(feature = "api-4-1") { count += 1; }
if cfg!(feature = "api-4-1-1") { count += 1; }
if cfg!(feature = "api-4-1-2") { count += 1; }
if cfg!(feature = "api-4-1-3") { count += 1; }
if cfg!(feature = "api-4-1-4") { count += 1; }
if cfg!(feature = "api-4-2") { count += 1; }
if cfg!(feature = "api-4-2-1") { count += 1; }
if cfg!(feature = "api-4-2-2") { count += 1; }
// ]]

assert!(count <= 1, "at most one `api-*` feature can be enabled");
}
Expand Down

0 comments on commit 3261dea

Please sign in to comment.