/// Turn a mplace into a (thin or fat) pointer, as a reference, pointing to the same space.
/// This is the inverse of `ref_to_mplace`.
+ /// `mutbl` indicates whether we are create a shared or mutable ref, or a raw pointer (`None`).
pub fn create_ref(
&mut self,
place: MPlaceTy<'tcx, M::PointerTag>,
- borrow_kind: Option<mir::BorrowKind>,
+ mutbl: Option<hir::Mutability>,
) -> EvalResult<'tcx, Value<M::PointerTag>> {
// Pointer tag tracking might want to adjust the tag
let place = if M::ENABLE_PTR_TRACKING_HOOKS {
let (size, _) = self.size_and_align_of_mplace(place)?
// for extern types, just cover what we can
.unwrap_or_else(|| place.layout.size_and_align());
- let mutbl = match borrow_kind {
- Some(mir::BorrowKind::Mut { .. }) |
- Some(mir::BorrowKind::Unique) =>
- Some(hir::MutMutable),
- Some(_) => Some(hir::MutImmutable),
- None => None,
- };
M::tag_reference(self, *place, place.layout.ty, size, mutbl)?
} else {
*place
//!
//! The main entry point is the `step` method.
-use rustc::mir;
+use rustc::{hir, mir};
use rustc::ty::layout::LayoutOf;
use rustc::mir::interpret::{EvalResult, Scalar, PointerArithmetic};
Ref(_, borrow_kind, ref place) => {
let src = self.eval_place(place)?;
let val = self.force_allocation(src)?;
- let val = self.create_ref(val, Some(borrow_kind))?;
+ let mutbl = match borrow_kind {
+ mir::BorrowKind::Mut { .. } |
+ mir::BorrowKind::Unique =>
+ hir::MutMutable,
+ mir::BorrowKind::Shared |
+ mir::BorrowKind::Shallow =>
+ hir::MutImmutable,
+ };
+ let val = self.create_ref(val, Some(mutbl))?;
self.write_value(val, dest)?;
}