提交 529b94ea 编写于 作者: W Wesley Wiser

[const-prop] Fix ICE when casting function pointers

This fixes an ICE when building libcore with `-Z mir-opt-level=3`.
上级 daf1ed0e
......@@ -525,12 +525,10 @@ fn replace_with_const(
source_info: SourceInfo,
) {
trace!("attepting to replace {:?} with {:?}", rval, value);
self.ecx.validate_operand(
value,
vec![],
None,
true,
).expect("value should already be a valid const");
if let Err(e) = self.ecx.validate_operand(value, vec![], None, true) {
trace!("validation error, attempt failed: {:?}", e);
return;
}
// FIXME> figure out what tho do when try_read_immediate fails
let imm = self.use_ecx(source_info, |this| {
......
fn main() {
let _ = main as usize as *const fn();
}
// END RUST SOURCE
// START rustc.main.ConstProp.before.mir
// bb0: {
// ...
// _3 = const main as fn() (Pointer(ReifyFnPointer));
// _2 = move _3 as usize (Misc);
// ...
// _1 = move _2 as *const fn() (Misc);
// ...
// }
// END rustc.main.ConstProp.before.mir
// START rustc.main.ConstProp.after.mir
// bb0: {
// ...
// _3 = const Scalar(AllocId(1).0x0) : fn();
// _2 = move _3 as usize (Misc);
// ...
// _1 = const Scalar(AllocId(1).0x0) : *const fn();
// ...
// }
// END rustc.main.ConstProp.after.mir
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册