mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-22 23:04:33 +00:00
review feedback
This commit is contained in:
parent
4101889786
commit
09a887cebf
@ -364,16 +364,16 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
|
||||
pub fn read_immediate_raw(
|
||||
&self,
|
||||
src: &OpTy<'tcx, M::Provenance>,
|
||||
) -> InterpResult<'tcx, Either<ImmTy<'tcx, M::Provenance>, MPlaceTy<'tcx, M::Provenance>>> {
|
||||
) -> InterpResult<'tcx, Either<MPlaceTy<'tcx, M::Provenance>, ImmTy<'tcx, M::Provenance>>> {
|
||||
Ok(match src.as_mplace_or_imm() {
|
||||
Left(ref mplace) => {
|
||||
if let Some(val) = self.read_immediate_from_mplace_raw(mplace)? {
|
||||
Left(val)
|
||||
Right(val)
|
||||
} else {
|
||||
Right(*mplace)
|
||||
Left(*mplace)
|
||||
}
|
||||
}
|
||||
Right(val) => Left(val),
|
||||
Right(val) => Right(val),
|
||||
})
|
||||
}
|
||||
|
||||
@ -392,7 +392,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
|
||||
) {
|
||||
span_bug!(self.cur_span(), "primitive read not possible for type: {:?}", op.layout.ty);
|
||||
}
|
||||
let imm = self.read_immediate_raw(op)?.left().unwrap();
|
||||
let imm = self.read_immediate_raw(op)?.right().unwrap();
|
||||
if matches!(*imm, Immediate::Uninit) {
|
||||
throw_ub!(InvalidUninitBytes(None));
|
||||
}
|
||||
|
@ -641,7 +641,7 @@ where
|
||||
// Let us see if the layout is simple so we take a shortcut,
|
||||
// avoid force_allocation.
|
||||
let src = match self.read_immediate_raw(src)? {
|
||||
Left(src_val) => {
|
||||
Right(src_val) => {
|
||||
// FIXME(const_prop): Const-prop can possibly evaluate an
|
||||
// unsized copy operation when it thinks that the type is
|
||||
// actually sized, due to a trivially false where-clause
|
||||
@ -671,7 +671,7 @@ where
|
||||
)
|
||||
};
|
||||
}
|
||||
Right(mplace) => mplace,
|
||||
Left(mplace) => mplace,
|
||||
};
|
||||
// Slow path, this does not fit into an immediate. Just memcpy.
|
||||
trace!("copy_op: {:?} <- {:?}: {}", *dest, src, dest.layout.ty);
|
||||
|
@ -147,13 +147,7 @@ impl IntRange {
|
||||
// straight to the result, after doing a bit of checking. (We
|
||||
// could remove this branch and just fall through, which
|
||||
// is more general but much slower.)
|
||||
if let either::Left(bits) =
|
||||
scalar.to_bits_or_ptr_internal(target_size).unwrap()
|
||||
{
|
||||
return Some(bits);
|
||||
} else {
|
||||
return None;
|
||||
}
|
||||
return scalar.to_bits_or_ptr_internal(target_size).unwrap().left();
|
||||
}
|
||||
mir::ConstantKind::Ty(c) => match c.kind() {
|
||||
ty::ConstKind::Value(_) => bug!(
|
||||
|
@ -3,7 +3,7 @@
|
||||
|
||||
use std::cell::Cell;
|
||||
|
||||
use either::Left;
|
||||
use either::Right;
|
||||
|
||||
use rustc_ast::Mutability;
|
||||
use rustc_data_structures::fx::FxHashSet;
|
||||
@ -431,7 +431,7 @@ impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> {
|
||||
// Try to read the local as an immediate so that if it is representable as a scalar, we can
|
||||
// handle it as such, but otherwise, just return the value as is.
|
||||
Some(match self.ecx.read_immediate_raw(&op) {
|
||||
Ok(Left(imm)) => imm.into(),
|
||||
Ok(Right(imm)) => imm.into(),
|
||||
_ => op,
|
||||
})
|
||||
}
|
||||
@ -745,7 +745,7 @@ impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> {
|
||||
// FIXME> figure out what to do when read_immediate_raw fails
|
||||
let imm = self.use_ecx(|this| this.ecx.read_immediate_raw(value));
|
||||
|
||||
if let Some(Left(imm)) = imm {
|
||||
if let Some(Right(imm)) = imm {
|
||||
match *imm {
|
||||
interpret::Immediate::Scalar(scalar) => {
|
||||
*rval = Rvalue::Use(self.operand_from_scalar(
|
||||
|
Loading…
Reference in New Issue
Block a user