Add regression test
This commit is contained in:
parent
0a689c1be8
commit
44e199bf30
1 changed files with 21 additions and 0 deletions
21
tests/ui/inline-const/promotion.rs
Normal file
21
tests/ui/inline-const/promotion.rs
Normal file
|
@ -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
|
||||||
|
};
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue