diff --git a/tests/ui/inline-const/promotion.rs b/tests/ui/inline-const/promotion.rs new file mode 100644 index 00000000000..e211f46acf9 --- /dev/null +++ b/tests/ui/inline-const/promotion.rs @@ -0,0 +1,21 @@ +#![feature(inline_const)] +#![allow(arithmetic_overflow, unconditional_panic)] +// check-pass + +// The only way to have promoteds that fail is in `const fn` called from `const`/`static`. +const fn div_by_zero() -> i32 { + 1 / 0 +} + +const fn mk_false() -> bool { + false +} + +fn main() { + let v = const { + if mk_false() { + let _x: &'static i32 = &div_by_zero(); + } + 42 + }; +}