miri: import ty::Ty directly.

This commit is contained in:
Eduard-Mihai Burtescu 2017-12-06 13:55:46 +02:00
parent 42a534c20a
commit bf5ec79725
6 changed files with 16 additions and 15 deletions

View file

@ -1,4 +1,4 @@
use ty::{self, Ty};
use ty::Ty;
use syntax::ast::{FloatTy, IntTy, UintTy};
use rustc_const_math::ConstFloat;
@ -37,7 +37,7 @@ impl<'a, 'tcx, M: Machine<'tcx>> EvalContext<'a, 'tcx, M> {
}
}
fn cast_from_signed_int(&self, val: i128, ty: ty::Ty<'tcx>) -> EvalResult<'tcx, PrimVal> {
fn cast_from_signed_int(&self, val: i128, ty: Ty<'tcx>) -> EvalResult<'tcx, PrimVal> {
self.cast_from_int(val as u128, ty, val < 0)
}
@ -71,7 +71,7 @@ impl<'a, 'tcx, M: Machine<'tcx>> EvalContext<'a, 'tcx, M> {
fn cast_from_int(
&self,
v: u128,
ty: ty::Ty<'tcx>,
ty: Ty<'tcx>,
negative: bool,
) -> EvalResult<'tcx, PrimVal> {
trace!("cast_from_int: {}, {}, {}", v, ty, negative);

View file

@ -274,7 +274,7 @@ impl<'tcx> super::Machine<'tcx> for CompileTimeFunctionEvaluator {
fn box_alloc<'a>(
_ecx: &mut EvalContext<'a, 'tcx, Self>,
_ty: ty::Ty<'tcx>,
_ty: Ty<'tcx>,
_dest: Place,
) -> EvalResult<'tcx> {
Err(

View file

@ -346,7 +346,7 @@ impl<'a, 'tcx, M: Machine<'tcx>> EvalContext<'a, 'tcx, M> {
/// the value has to be a fat pointer, and we only care about the "extra" data in it.
pub fn size_and_align_of_dst(
&mut self,
ty: ty::Ty<'tcx>,
ty: Ty<'tcx>,
value: Value,
) -> EvalResult<'tcx, (Size, Align)> {
let layout = self.layout_of(ty)?;

View file

@ -4,7 +4,8 @@
use super::{EvalResult, EvalContext, Place, PrimVal, ValTy};
use {mir, ty};
use mir;
use ty::{self, Ty};
use syntax::codemap::Span;
use syntax::ast::Mutability;
@ -60,9 +61,9 @@ pub trait Machine<'tcx>: Sized {
ecx: &EvalContext<'a, 'tcx, Self>,
bin_op: mir::BinOp,
left: PrimVal,
left_ty: ty::Ty<'tcx>,
left_ty: Ty<'tcx>,
right: PrimVal,
right_ty: ty::Ty<'tcx>,
right_ty: Ty<'tcx>,
) -> EvalResult<'tcx, Option<(PrimVal, bool)>>;
/// Called when trying to mark machine defined `MemoryKinds` as static
@ -73,7 +74,7 @@ pub trait Machine<'tcx>: Sized {
/// Returns a pointer to the allocated memory
fn box_alloc<'a>(
ecx: &mut EvalContext<'a, 'tcx, Self>,
ty: ty::Ty<'tcx>,
ty: Ty<'tcx>,
dest: Place,
) -> EvalResult<'tcx>;

View file

@ -1,5 +1,5 @@
use mir;
use ty::{self, TypeVariants};
use ty::{self, Ty};
use ty::layout::LayoutOf;
use syntax::codemap::Span;
use syntax::abi::Abi;
@ -177,7 +177,7 @@ impl<'a, 'tcx, M: Machine<'tcx>> EvalContext<'a, 'tcx, M> {
sig: ty::FnSig<'tcx>,
real_sig: ty::FnSig<'tcx>,
) -> EvalResult<'tcx, bool> {
fn check_ty_compat<'tcx>(ty: ty::Ty<'tcx>, real_ty: ty::Ty<'tcx>) -> bool {
fn check_ty_compat<'tcx>(ty: Ty<'tcx>, real_ty: Ty<'tcx>) -> bool {
if ty == real_ty {
return true;
} // This is actually a fast pointer comparison
@ -185,8 +185,8 @@ impl<'a, 'tcx, M: Machine<'tcx>> EvalContext<'a, 'tcx, M> {
// Permit changing the pointer type of raw pointers and references as well as
// mutability of raw pointers.
// TODO: Should not be allowed when fat pointers are involved.
(&TypeVariants::TyRawPtr(_), &TypeVariants::TyRawPtr(_)) => true,
(&TypeVariants::TyRef(_, _), &TypeVariants::TyRef(_, _)) => {
(&ty::TyRawPtr(_), &ty::TyRawPtr(_)) => true,
(&ty::TyRef(_, _), &ty::TyRef(_, _)) => {
ty.is_mutable_pointer() == real_ty.is_mutable_pointer()
}
// rule out everything else
@ -220,7 +220,7 @@ impl<'a, 'tcx, M: Machine<'tcx>> EvalContext<'a, 'tcx, M> {
// Second argument must be a tuple matching the argument list of sig
let snd_ty = real_sig.inputs_and_output[1];
match snd_ty.sty {
TypeVariants::TyTuple(tys, _) if sig.inputs().len() == tys.len() =>
ty::TyTuple(tys, _) if sig.inputs().len() == tys.len() =>
if sig.inputs().iter().zip(tys).all(|(ty, real_ty)| check_ty_compat(ty, real_ty)) {
return Ok(true)
},

View file

@ -337,7 +337,7 @@ impl<'a, 'tcx, M: Machine<'tcx>> EvalContext<'a, 'tcx, M> {
base: Place,
mut layout: ty::layout::TyLayout<'tcx>,
i: usize,
) -> EvalResult<'tcx, ty::Ty<'tcx>> {
) -> EvalResult<'tcx, Ty<'tcx>> {
match base {
Place::Ptr { extra: PlaceExtra::DowncastVariant(variant_index), .. } => {
layout = layout.for_variant(&self, variant_index);