2023-09-18 10:20:36 -05:00
|
|
|
#![allow(arithmetic_overflow, unconditional_panic)]
|
|
|
|
|
|
|
|
// The only way to have promoteds that fail is in `const fn` called from `const`/`static`.
|
2023-09-18 10:30:07 -05:00
|
|
|
// Make sure that in a `const` block, we do not promote such calls.
|
2023-09-18 10:20:36 -05:00
|
|
|
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();
|
2023-09-18 10:30:07 -05:00
|
|
|
//~^ ERROR: temporary value dropped while borrowed
|
2023-09-18 10:20:36 -05:00
|
|
|
}
|
|
|
|
42
|
|
|
|
};
|
|
|
|
}
|