}
}
-impl_stable_hash_for!(struct mir::ValidationOperand<'tcx> { lval, ty, re, mutbl });
+impl<'a, 'gcx, 'tcx, T> HashStable<StableHashingContext<'a, 'gcx, 'tcx>> for mir::ValidationOperand<'tcx, T>
+ where T: HashStable<StableHashingContext<'a, 'gcx, 'tcx>>
+{
+ fn hash_stable<W: StableHasherResult>(&self,
+ hcx: &mut StableHashingContext<'a, 'gcx, 'tcx>,
+ hasher: &mut StableHasher<W>)
+ {
+ 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) });
},
/// Assert the given lvalues to be valid inhabitants of their type.
- Validate(ValidationOp, Vec<ValidationOperand<'tcx>>),
+ Validate(ValidationOp, Vec<ValidationOperand<'tcx, Lvalue<'tcx>>>),
/// Mark one terminating point of an extent (i.e. static region).
/// (The starting point(s) arise implicitly from borrows.)
}
}
+// 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<CodeExtent>,
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 {
}
}
-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),
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 }