diff --git a/tests/ui/consts/control-flow/dead_branches_dont_eval.rs b/tests/ui/consts/control-flow/dead_branches_dont_eval.rs new file mode 100644 index 0000000000000..49158ba85a963 --- /dev/null +++ b/tests/ui/consts/control-flow/dead_branches_dont_eval.rs @@ -0,0 +1,26 @@ +//@ check-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 { + || {} + }; +} + +fn main() { + Invoke::<(), 0>::FUN(); +}