[const-prop] Replace Cast
handling with use of InterpCx
This commit is contained in:
parent
86c7c4d7be
commit
ecc4cc2fc4
@ -24,7 +24,7 @@
|
||||
|
||||
use crate::interpret::{
|
||||
self, InterpCx, ScalarMaybeUndef, Immediate, OpTy,
|
||||
ImmTy, MemoryKind, StackPopCleanup, LocalValue, LocalState,
|
||||
ImmTy, StackPopCleanup, LocalValue, LocalState,
|
||||
};
|
||||
use crate::const_eval::{
|
||||
CompileTimeInterpreter, error_to_const_error, mk_eval_cx,
|
||||
@ -305,7 +305,8 @@ fn const_prop(
|
||||
let span = source_info.span;
|
||||
match *rvalue {
|
||||
Rvalue::Use(_) |
|
||||
Rvalue::Len(_) => {
|
||||
Rvalue::Len(_) |
|
||||
Rvalue::Cast(..) => {
|
||||
self.use_ecx(source_info, |this| {
|
||||
this.ecx.eval_rvalue_into_place(rvalue, place)?;
|
||||
this.ecx.eval_place_to_op(place, Some(place_layout))
|
||||
@ -321,14 +322,6 @@ fn const_prop(
|
||||
Rvalue::NullaryOp(NullOp::Box, _) |
|
||||
Rvalue::Discriminant(..) => None,
|
||||
|
||||
Rvalue::Cast(kind, ref operand, _) => {
|
||||
let op = self.eval_operand(operand, source_info)?;
|
||||
self.use_ecx(source_info, |this| {
|
||||
let dest = this.ecx.allocate(place_layout, MemoryKind::Stack);
|
||||
this.ecx.cast(op, kind, dest.into())?;
|
||||
Ok(dest.into())
|
||||
})
|
||||
},
|
||||
Rvalue::NullaryOp(NullOp::SizeOf, ty) => {
|
||||
type_size_of(self.tcx, self.param_env, ty).and_then(|n| Some(
|
||||
ImmTy::from_uint(
|
||||
|
@ -16,7 +16,7 @@ fn main() {
|
||||
// START rustc.main.ConstProp.after.mir
|
||||
// bb0: {
|
||||
// ...
|
||||
// _3 = const Scalar(AllocId(1).0x0) : fn();
|
||||
// _3 = const Scalar(AllocId(0).0x0) : fn();
|
||||
// _2 = move _3 as usize (Misc);
|
||||
// ...
|
||||
// _1 = move _2 as *const fn() (Misc);
|
||||
|
Loading…
Reference in New Issue
Block a user