Conditional compilation via if statements


#1

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).


#2

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.