Conditional compilation via if statements


How does the Rust compiler analyze, diagnose and optimize if-expressions that are compile-time constants. For instance such as in


In D, static if should have been used instead. And the D compilers warn when the if-expression is a compile-time constant (D enum).


Insofar as I know, it hopes LLVM optimises the branch out.

If you want guaranteed conditional compilation, you need to resort to #[cfg(...)]-ing items, or a cfg-branch macro.