macro
compile_error! — Reject unsupported build settings
Emit a compiler diagnostic when the invocation is expanded. Combine with a cfg attribute to reject unsupported configurations. Unlike panic!, this prevents successful compilation rather than stopping a running program. Result: No successful expansion in the active configuration. Expected output (not executed): 'Build accepted\n' Common mistake: Placing compile_error! in an ordinary if false branch and expecting it not to expand.
Formal Syntax & Structure
rust syntaxrust
compile_error!("message")Working Example
Example Snippetrust
#[cfg(bytemind_unsupported)]compile_error!("This training build is unsupported");fn main() { println!("Build accepted");}