diff --git a/src/librustc/ich/impls_mir.rs b/src/librustc/ich/impls_mir.rs index dc41f981ed57..bef35fdc2578 100644 --- a/src/librustc/ich/impls_mir.rs +++ b/src/librustc/ich/impls_mir.rs @@ -243,7 +243,19 @@ for mir::StatementKind<'tcx> { } } -impl_stable_hash_for!(struct mir::ValidationOperand<'tcx> { lval, ty, re, mutbl }); +impl<'a, 'gcx, 'tcx, T> HashStable> for mir::ValidationOperand<'tcx, T> + where T: HashStable> +{ + fn hash_stable(&self, + hcx: &mut StableHashingContext<'a, 'gcx, 'tcx>, + hasher: &mut StableHasher) + { + self.lval.hash_stable(hcx, hasher); + self.ty.hash_stable(hcx, hasher); + self.re.hash_stable(hcx, hasher); + self.mutbl.hash_stable(hcx, hasher); + } +} impl_stable_hash_for!(enum mir::ValidationOp { Acquire, Release, Suspend(extent) }); diff --git a/src/librustc/mir/mod.rs b/src/librustc/mir/mod.rs index 4655f8a9c15e..f8261f806296 100644 --- a/src/librustc/mir/mod.rs +++ b/src/librustc/mir/mod.rs @@ -826,7 +826,7 @@ pub enum StatementKind<'tcx> { }, /// Assert the given lvalues to be valid inhabitants of their type. - Validate(ValidationOp, Vec>), + Validate(ValidationOp, Vec>>), /// Mark one terminating point of an extent (i.e. static region). /// (The starting point(s) arise implicitly from borrows.) @@ -855,15 +855,16 @@ impl Debug for ValidationOp { } } +// This is generic so that it can be reused by miri #[derive(Clone, RustcEncodable, RustcDecodable)] -pub struct ValidationOperand<'tcx> { - pub lval: Lvalue<'tcx>, +pub struct ValidationOperand<'tcx, T> { + pub lval: T, pub ty: Ty<'tcx>, pub re: Option, pub mutbl: hir::Mutability, } -impl<'tcx> Debug for ValidationOperand<'tcx> { +impl<'tcx, T: Debug> Debug for ValidationOperand<'tcx, T> { fn fmt(&self, fmt: &mut Formatter) -> fmt::Result { write!(fmt, "{:?}@{:?}", self.lval, self.ty)?; if let Some(ce) = self.re { @@ -1527,7 +1528,7 @@ impl<'tcx> TypeFoldable<'tcx> for BasicBlockData<'tcx> { } } -impl<'tcx> TypeFoldable<'tcx> for ValidationOperand<'tcx> { +impl<'tcx> TypeFoldable<'tcx> for ValidationOperand<'tcx, Lvalue<'tcx>> { fn super_fold_with<'gcx: 'tcx, F: TypeFolder<'gcx, 'tcx>>(&self, folder: &mut F) -> Self { ValidationOperand { lval: self.lval.fold_with(folder), diff --git a/src/librustc_mir/transform/add_validation.rs b/src/librustc_mir/transform/add_validation.rs index 1fe16fb98f22..005d793cd8b5 100644 --- a/src/librustc_mir/transform/add_validation.rs +++ b/src/librustc_mir/transform/add_validation.rs @@ -88,7 +88,7 @@ impl MirPass for AddValidation { let local_decls = mir.local_decls.clone(); // TODO: Find a way to get rid of this clone. /// Convert an lvalue to a validation operand. - let lval_to_operand = |lval: Lvalue<'tcx>| -> ValidationOperand<'tcx> { + let lval_to_operand = |lval: Lvalue<'tcx>| -> ValidationOperand<'tcx, Lvalue<'tcx>> { let (re, mutbl) = lval_context(&lval, &local_decls, tcx); let ty = lval.ty(&local_decls, tcx).to_ty(tcx); ValidationOperand { lval, ty, re, mutbl }