//@ build-pass // issue 122301 - currently the only way to supress // const eval and codegen of code conditional on some other const struct Foo(T); impl Foo { const BAR: () = if N == 0 { panic!() }; } struct Invoke(T); impl Invoke { const FUN: fn() = if N != 0 { || Foo::::BAR } else { || {} }; } // without closures struct S(T); impl S { const C: () = panic!(); } const fn bar() { S::::C } struct ConstIf(T); impl ConstIf { const VAL: () = if N != 0 { bar::() // not called for N == 0, and hence not monomorphized } else { () }; } fn main() { let _val = Invoke::<(), 0>::FUN(); let _val = ConstIf::<(), 0>::VAL; }