compilation_guard

Attribute Macro compilation_guard 

Source
#[compilation_guard]
Expand description

Forces compilation to fail.

e.g.

#![allow(unused_imports, dead_code)]
 
use compilation_guard::compilation_guard;
#[cfg_attr(all(unstable, feature = "enable-macro"), derive(VeryExpensiveMacro))]
#[cfg_attr(all(not(unstable), feature = "enable-macro"), compilation_guard("lol"))]
struct A;
 
fn main() {
 
}

If you don’t enable the unstable flag, you get this.

error: custom attribute panicked
 --> src/main.rs:5:58
  |
5 | #[cfg_attr(all(not(unstable), feature = "enable-macro"), compilation_guard("lol"))]
  |                                                          ^^^^^^^^^^^^^^^^^^^^^^^^
  |
  = help: message: Compilation guard was triggered!
          lol