blob: 242959c6b51643f058a2b4b29f6ee0eb1c9074aa (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
#![feature(inline_const)]
#![allow(arithmetic_overflow, unconditional_panic)]
// The only way to have promoteds that fail is in `const fn` called from `const`/`static`.
// Make sure that in a `const` block, we do not promote such calls.
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();
//~^ ERROR: temporary value dropped while borrowed
}
42
};
}
|