rust/src/librustc_error_codes/error_codes/E0015.md

537 B

The only functions that can be called in static or constant expressions are const functions, and struct/enum constructors. const functions are only available on a nightly compiler. Rust currently does not support more general compile-time function execution.

const FOO: Option<u8> = Some(1); // enum constructor
struct Bar {x: u8}
const BAR: Bar = Bar {x: 1}; // struct constructor

See RFC 911 for more details on the design of const fns.