mirror of
https://github.com/rust-lang/rust.git
synced 2025-04-28 02:57:37 +00:00
use ImmTy::from_uint in a few more spots
This commit is contained in:
parent
3edf099266
commit
5ac2045d1e
@ -19,7 +19,7 @@ use syntax_pos::{Span, DUMMY_SP};
|
||||
use rustc::ty::subst::InternalSubsts;
|
||||
use rustc_data_structures::indexed_vec::IndexVec;
|
||||
use rustc::ty::layout::{
|
||||
LayoutOf, TyLayout, LayoutError, HasTyCtxt, TargetDataLayout, HasDataLayout, Size,
|
||||
LayoutOf, TyLayout, LayoutError, HasTyCtxt, TargetDataLayout, HasDataLayout,
|
||||
};
|
||||
|
||||
use crate::interpret::{
|
||||
@ -396,17 +396,10 @@ impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> {
|
||||
if let ty::Slice(_) = mplace.layout.ty.sty {
|
||||
let len = mplace.meta.unwrap().to_usize(&self.ecx).unwrap();
|
||||
|
||||
Some(ImmTy {
|
||||
imm: Immediate::Scalar(
|
||||
Scalar::from_uint(
|
||||
len,
|
||||
Size::from_bits(
|
||||
self.tcx.sess.target.usize_ty.bit_width().unwrap() as u64
|
||||
)
|
||||
).into(),
|
||||
),
|
||||
layout: self.tcx.layout_of(self.param_env.and(self.tcx.types.usize)).ok()?,
|
||||
}.into())
|
||||
Some(ImmTy::from_uint(
|
||||
len,
|
||||
self.tcx.layout_of(self.param_env.and(self.tcx.types.usize)).ok()?,
|
||||
).into())
|
||||
} else {
|
||||
trace!("not slice: {:?}", mplace.layout.ty.sty);
|
||||
None
|
||||
@ -414,12 +407,10 @@ impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> {
|
||||
},
|
||||
Rvalue::NullaryOp(NullOp::SizeOf, ty) => {
|
||||
type_size_of(self.tcx, self.param_env, ty).and_then(|n| Some(
|
||||
ImmTy {
|
||||
imm: Immediate::Scalar(
|
||||
Scalar::from_uint(n, self.tcx.data_layout.pointer_size).into()
|
||||
),
|
||||
layout: self.tcx.layout_of(self.param_env.and(self.tcx.types.usize)).ok()?,
|
||||
}.into()
|
||||
ImmTy::from_uint(
|
||||
n,
|
||||
self.tcx.layout_of(self.param_env.and(self.tcx.types.usize)).ok()?,
|
||||
).into()
|
||||
))
|
||||
}
|
||||
Rvalue::UnaryOp(op, ref arg) => {
|
||||
|
Loading…
Reference in New Issue
Block a user