Do not assert in op_to_const.
This commit is contained in:
parent
146dafa262
commit
c2f49e9edf
@ -132,8 +132,8 @@ pub(super) fn op_to_const<'tcx>(
|
||||
// functionality.)
|
||||
_ => false,
|
||||
};
|
||||
let immediate = if force_as_immediate {
|
||||
Right(ecx.read_immediate(op).expect("normalization works on validated constants"))
|
||||
let immediate = if force_as_immediate && let Ok(imm) = ecx.read_immediate(op) {
|
||||
Right(imm)
|
||||
} else {
|
||||
op.as_mplace_or_imm()
|
||||
};
|
||||
|
11
tests/ui/mir/issue-117368-print-invalid-constant.rs
Normal file
11
tests/ui/mir/issue-117368-print-invalid-constant.rs
Normal file
@ -0,0 +1,11 @@
|
||||
// build-pass
|
||||
// compile-flags:-Zmir-opt-level=4 --emit=mir
|
||||
|
||||
#![feature(allocator_api)]
|
||||
|
||||
use std::alloc::{Allocator, Global, Layout};
|
||||
|
||||
fn main() {
|
||||
let layout: Layout = None.unwrap();
|
||||
let ptr: *mut u8 = Global.allocate(layout).unwrap().as_ptr() as _;
|
||||
}
|
Loading…
Reference in New Issue
Block a user