keep root_span and tcx together
This commit is contained in:
parent
c6512fd4e9
commit
2210abea71
|
@ -27,7 +27,7 @@ fn eval_body_using_ecx<'mir, 'tcx>(
|
|||
body: &'mir mir::Body<'tcx>,
|
||||
) -> InterpResult<'tcx, MPlaceTy<'tcx>> {
|
||||
debug!("eval_body_using_ecx: {:?}, {:?}", cid, ecx.param_env);
|
||||
let tcx = ecx.tcx;
|
||||
let tcx = *ecx.tcx;
|
||||
let layout = ecx.layout_of(body.return_ty().subst(tcx, cid.instance.substs))?;
|
||||
assert!(!layout.is_unsized());
|
||||
let ret = ecx.allocate(layout, MemoryKind::Stack);
|
||||
|
@ -214,7 +214,7 @@ fn validate_and_turn_into_const<'tcx>(
|
|||
|
||||
val.map_err(|error| {
|
||||
let err = error_to_const_error(&ecx, error, None);
|
||||
err.struct_error(ecx.tcx_at(), "it is undefined behavior to use this value", |mut diag| {
|
||||
err.struct_error(ecx.tcx, "it is undefined behavior to use this value", |mut diag| {
|
||||
diag.note(note_on_undefined_behavior_error());
|
||||
diag.emit();
|
||||
})
|
||||
|
|
|
@ -56,7 +56,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
|
|||
}
|
||||
|
||||
let instance = ty::Instance::resolve_for_fn_ptr(
|
||||
self.tcx,
|
||||
*self.tcx,
|
||||
self.param_env,
|
||||
def_id,
|
||||
substs,
|
||||
|
@ -91,7 +91,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
|
|||
}
|
||||
|
||||
let instance = ty::Instance::resolve_closure(
|
||||
self.tcx,
|
||||
*self.tcx,
|
||||
def_id,
|
||||
substs,
|
||||
ty::ClosureKind::FnOnce,
|
||||
|
@ -140,7 +140,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
|
|||
// Handle cast from a univariant (ZST) enum.
|
||||
match src.layout.variants {
|
||||
Variants::Single { index } => {
|
||||
if let Some(discr) = src.layout.ty.discriminant_for_variant(self.tcx, index) {
|
||||
if let Some(discr) = src.layout.ty.discriminant_for_variant(*self.tcx, index) {
|
||||
assert!(src.layout.is_zst());
|
||||
let discr_layout = self.layout_of(discr.ty)?;
|
||||
return Ok(self.cast_from_scalar(discr.val, discr_layout, cast_ty).into());
|
||||
|
@ -269,7 +269,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
|
|||
let ptr = self.read_immediate(src)?.to_scalar()?;
|
||||
// u64 cast is from usize to u64, which is always good
|
||||
let val =
|
||||
Immediate::new_slice(ptr, length.eval_usize(self.tcx, self.param_env), self);
|
||||
Immediate::new_slice(ptr, length.eval_usize(*self.tcx, self.param_env), self);
|
||||
self.write_immediate(val, dest)
|
||||
}
|
||||
(&ty::Dynamic(..), &ty::Dynamic(..)) => {
|
||||
|
|
|
@ -33,11 +33,9 @@ pub struct InterpCx<'mir, 'tcx, M: Machine<'mir, 'tcx>> {
|
|||
pub machine: M,
|
||||
|
||||
/// The results of the type checker, from rustc.
|
||||
pub tcx: TyCtxt<'tcx>,
|
||||
|
||||
/// The span of the "root" of the evaluation, i.e., the const
|
||||
/// The span in this is the "root" of the evaluation, i.e., the const
|
||||
/// we are evaluating (if this is CTFE).
|
||||
pub(super) root_span: Span,
|
||||
pub tcx: TyCtxtAt<'tcx>,
|
||||
|
||||
/// Bounds in scope for polymorphic evaluations.
|
||||
pub(crate) param_env: ty::ParamEnv<'tcx>,
|
||||
|
@ -200,7 +198,7 @@ where
|
|||
{
|
||||
#[inline]
|
||||
fn tcx(&self) -> TyCtxt<'tcx> {
|
||||
self.tcx
|
||||
*self.tcx
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -219,7 +217,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> LayoutOf for InterpCx<'mir, 'tcx,
|
|||
|
||||
#[inline]
|
||||
fn layout_of(&self, ty: Ty<'tcx>) -> Self::TyAndLayout {
|
||||
self.tcx_at()
|
||||
self.tcx
|
||||
.layout_of(self.param_env.and(ty))
|
||||
.map_err(|layout| err_inval!(Layout(layout)).into())
|
||||
}
|
||||
|
@ -304,8 +302,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
|
|||
) -> Self {
|
||||
InterpCx {
|
||||
machine,
|
||||
tcx,
|
||||
root_span,
|
||||
tcx: tcx.at(root_span),
|
||||
param_env,
|
||||
memory: Memory::new(tcx, memory_extra),
|
||||
vtables: FxHashMap::default(),
|
||||
|
@ -318,14 +315,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
|
|||
.last()
|
||||
.and_then(|f| f.current_source_info())
|
||||
.map(|si| si.span)
|
||||
.unwrap_or(self.root_span)
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
pub fn tcx_at(&self) -> TyCtxtAt<'tcx> {
|
||||
// Computing the current span has a non-trivial cost, and for cycle errors
|
||||
// the "root span" is good enough.
|
||||
self.tcx.at(self.root_span)
|
||||
.unwrap_or(self.tcx.span)
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
|
@ -403,12 +393,12 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
|
|||
|
||||
#[inline]
|
||||
pub fn type_is_sized(&self, ty: Ty<'tcx>) -> bool {
|
||||
ty.is_sized(self.tcx_at(), self.param_env)
|
||||
ty.is_sized(self.tcx, self.param_env)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn type_is_freeze(&self, ty: Ty<'tcx>) -> bool {
|
||||
ty.is_freeze(self.tcx, self.param_env, self.root_span)
|
||||
ty.is_freeze(*self.tcx, self.param_env, self.tcx.span)
|
||||
}
|
||||
|
||||
pub fn load_mir(
|
||||
|
@ -419,21 +409,20 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
|
|||
// do not continue if typeck errors occurred (can only occur in local crate)
|
||||
let did = instance.def_id();
|
||||
if let Some(did) = did.as_local() {
|
||||
if self.tcx_at().has_typeck_tables(did) {
|
||||
if let Some(error_reported) = self.tcx_at().typeck_tables_of(did).tainted_by_errors
|
||||
{
|
||||
if self.tcx.has_typeck_tables(did) {
|
||||
if let Some(error_reported) = self.tcx.typeck_tables_of(did).tainted_by_errors {
|
||||
throw_inval!(TypeckError(error_reported))
|
||||
}
|
||||
}
|
||||
}
|
||||
trace!("load mir(instance={:?}, promoted={:?})", instance, promoted);
|
||||
if let Some(promoted) = promoted {
|
||||
return Ok(&self.tcx_at().promoted_mir(did)[promoted]);
|
||||
return Ok(&self.tcx.promoted_mir(did)[promoted]);
|
||||
}
|
||||
match instance {
|
||||
ty::InstanceDef::Item(def_id) => {
|
||||
if self.tcx_at().is_mir_available(did) {
|
||||
Ok(self.tcx_at().optimized_mir(did))
|
||||
if self.tcx.is_mir_available(did) {
|
||||
Ok(self.tcx.optimized_mir(did))
|
||||
} else {
|
||||
throw_unsup!(NoMirFor(def_id))
|
||||
}
|
||||
|
@ -474,7 +463,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
|
|||
trace!("resolve: {:?}, {:#?}", def_id, substs);
|
||||
trace!("param_env: {:#?}", self.param_env);
|
||||
trace!("substs: {:#?}", substs);
|
||||
match ty::Instance::resolve(self.tcx, self.param_env, def_id, substs) {
|
||||
match ty::Instance::resolve(*self.tcx, self.param_env, def_id, substs) {
|
||||
Ok(Some(instance)) => Ok(instance),
|
||||
Ok(None) => throw_inval!(TooGeneric),
|
||||
|
||||
|
@ -493,7 +482,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
|
|||
// have to support that case (mostly by skipping all caching).
|
||||
match frame.locals.get(local).and_then(|state| state.layout.get()) {
|
||||
None => {
|
||||
let layout = from_known_layout(self.tcx_at(), layout, || {
|
||||
let layout = from_known_layout(self.tcx, layout, || {
|
||||
let local_ty = frame.body.local_decls[local].ty;
|
||||
let local_ty =
|
||||
self.subst_from_frame_and_normalize_erasing_regions(frame, local_ty);
|
||||
|
@ -645,7 +634,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
|
|||
let mut locals = IndexVec::from_elem(dummy, &body.local_decls);
|
||||
|
||||
// Now mark those locals as dead that we do not want to initialize
|
||||
match self.tcx_at().def_kind(instance.def_id()) {
|
||||
match self.tcx.def_kind(instance.def_id()) {
|
||||
// statics and constants don't have `Storage*` statements, no need to look for them
|
||||
//
|
||||
// FIXME: The above is likely untrue. See
|
||||
|
@ -860,7 +849,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
|
|||
} else {
|
||||
self.param_env
|
||||
};
|
||||
let val = self.tcx.const_eval_global_id(param_env, gid, Some(self.root_span))?;
|
||||
let val = self.tcx.const_eval_global_id(param_env, gid, Some(self.tcx.span))?;
|
||||
|
||||
// Even though `ecx.const_eval` is called from `eval_const_to_op` we can never have a
|
||||
// recursion deeper than one level, because the `tcx.const_eval` above is guaranteed to not
|
||||
|
@ -891,7 +880,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
|
|||
// FIXME: We can hit delay_span_bug if this is an invalid const, interning finds
|
||||
// that problem, but we never run validation to show an error. Can we ensure
|
||||
// this does not happen?
|
||||
let val = self.tcx_at().const_eval_raw(param_env.and(gid))?;
|
||||
let val = self.tcx.const_eval_raw(param_env.and(gid))?;
|
||||
self.raw_const_to_mplace(val)
|
||||
}
|
||||
|
||||
|
|
|
@ -93,7 +93,7 @@ fn intern_shallow<'rt, 'mir, 'tcx, M: CompileTimeMachine<'mir, 'tcx>>(
|
|||
// in the value the dangling reference lies.
|
||||
// The `delay_span_bug` ensures that we don't forget such a check in validation.
|
||||
if tcx.get_global_alloc(alloc_id).is_none() {
|
||||
tcx.sess.delay_span_bug(ecx.root_span, "tried to intern dangling pointer");
|
||||
tcx.sess.delay_span_bug(ecx.tcx.span, "tried to intern dangling pointer");
|
||||
}
|
||||
// treat dangling pointers like other statics
|
||||
// just to stop trying to recurse into them
|
||||
|
@ -111,7 +111,7 @@ fn intern_shallow<'rt, 'mir, 'tcx, M: CompileTimeMachine<'mir, 'tcx>>(
|
|||
if let InternMode::Static(mutability) = mode {
|
||||
// For this, we need to take into account `UnsafeCell`. When `ty` is `None`, we assume
|
||||
// no interior mutability.
|
||||
let frozen = ty.map_or(true, |ty| ty.is_freeze(ecx.tcx, ecx.param_env, ecx.root_span));
|
||||
let frozen = ty.map_or(true, |ty| ty.is_freeze(*ecx.tcx, ecx.param_env, ecx.tcx.span));
|
||||
// For statics, allocation mutability is the combination of the place mutability and
|
||||
// the type mutability.
|
||||
// The entire allocation needs to be mutable if it contains an `UnsafeCell` anywhere.
|
||||
|
@ -174,7 +174,7 @@ impl<'rt, 'mir, 'tcx: 'mir, M: CompileTimeMachine<'mir, 'tcx>> ValueVisitor<'mir
|
|||
// they caused. It also helps us to find cases where const-checking
|
||||
// failed to prevent an `UnsafeCell` (but as `ignore_interior_mut_in_const`
|
||||
// shows that part is not airtight).
|
||||
mutable_memory_in_const(self.ecx.tcx_at(), "`UnsafeCell`");
|
||||
mutable_memory_in_const(self.ecx.tcx, "`UnsafeCell`");
|
||||
}
|
||||
// We are crossing over an `UnsafeCell`, we can mutate again. This means that
|
||||
// References we encounter inside here are interned as pointing to mutable
|
||||
|
@ -192,7 +192,7 @@ impl<'rt, 'mir, 'tcx: 'mir, M: CompileTimeMachine<'mir, 'tcx>> ValueVisitor<'mir
|
|||
fn visit_value(&mut self, mplace: MPlaceTy<'tcx>) -> InterpResult<'tcx> {
|
||||
// Handle Reference types, as these are the only relocations supported by const eval.
|
||||
// Raw pointers (and boxes) are handled by the `leftover_relocations` logic.
|
||||
let tcx = self.ecx.tcx.at(self.ecx.root_span);
|
||||
let tcx = self.ecx.tcx;
|
||||
let ty = mplace.layout.ty;
|
||||
if let ty::Ref(_, referenced_ty, ref_mutability) = ty.kind {
|
||||
let value = self.ecx.read_immediate(mplace.into())?;
|
||||
|
@ -253,8 +253,7 @@ impl<'rt, 'mir, 'tcx: 'mir, M: CompileTimeMachine<'mir, 'tcx>> ValueVisitor<'mir
|
|||
// caused (by somehow getting a mutable reference in a `const`).
|
||||
if ref_mutability == Mutability::Mut {
|
||||
match referenced_ty.kind {
|
||||
ty::Array(_, n)
|
||||
if n.eval_usize(self.ecx.tcx, self.ecx.param_env) == 0 => {}
|
||||
ty::Array(_, n) if n.eval_usize(*tcx, self.ecx.param_env) == 0 => {}
|
||||
ty::Slice(_)
|
||||
if mplace.meta.unwrap_meta().to_machine_usize(self.ecx)?
|
||||
== 0 => {}
|
||||
|
@ -358,7 +357,7 @@ pub fn intern_const_alloc_recursive<M: CompileTimeMachine<'mir, 'tcx>>(
|
|||
Ok(()) => {}
|
||||
Err(error) => {
|
||||
ecx.tcx.sess.delay_span_bug(
|
||||
ecx.root_span,
|
||||
ecx.tcx.span,
|
||||
"error during interning should later cause validation failure",
|
||||
);
|
||||
// Some errors shouldn't come up because creating them causes
|
||||
|
@ -407,7 +406,7 @@ pub fn intern_const_alloc_recursive<M: CompileTimeMachine<'mir, 'tcx>>(
|
|||
// such as `const CONST_RAW: *const Vec<i32> = &Vec::new() as *const _;`.
|
||||
ecx.tcx
|
||||
.sess
|
||||
.span_err(ecx.root_span, "untyped pointers are not allowed in constant");
|
||||
.span_err(ecx.tcx.span, "untyped pointers are not allowed in constant");
|
||||
// For better errors later, mark the allocation as immutable.
|
||||
alloc.mutability = Mutability::Not;
|
||||
}
|
||||
|
@ -422,11 +421,11 @@ pub fn intern_const_alloc_recursive<M: CompileTimeMachine<'mir, 'tcx>>(
|
|||
} else if ecx.memory.dead_alloc_map.contains_key(&alloc_id) {
|
||||
// Codegen does not like dangling pointers, and generally `tcx` assumes that
|
||||
// all allocations referenced anywhere actually exist. So, make sure we error here.
|
||||
ecx.tcx.sess.span_err(ecx.root_span, "encountered dangling pointer in final constant");
|
||||
ecx.tcx.sess.span_err(ecx.tcx.span, "encountered dangling pointer in final constant");
|
||||
} else if ecx.tcx.get_global_alloc(alloc_id).is_none() {
|
||||
// We have hit an `AllocId` that is neither in local or global memory and isn't
|
||||
// marked as dangling by local memory. That should be impossible.
|
||||
span_bug!(ecx.root_span, "encountered unknown alloc id {:?}", alloc_id);
|
||||
span_bug!(ecx.tcx.span, "encountered unknown alloc id {:?}", alloc_id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -347,7 +347,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
|
|||
let index = u64::from(self.read_scalar(args[1])?.to_u32()?);
|
||||
let elem = args[2];
|
||||
let input = args[0];
|
||||
let (len, e_ty) = input.layout.ty.simd_size_and_type(self.tcx);
|
||||
let (len, e_ty) = input.layout.ty.simd_size_and_type(*self.tcx);
|
||||
assert!(
|
||||
index < len,
|
||||
"Index `{}` must be in bounds of vector type `{}`: `[0, {})`",
|
||||
|
@ -374,7 +374,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
|
|||
}
|
||||
sym::simd_extract => {
|
||||
let index = u64::from(self.read_scalar(args[1])?.to_u32()?);
|
||||
let (len, e_ty) = args[0].layout.ty.simd_size_and_type(self.tcx);
|
||||
let (len, e_ty) = args[0].layout.ty.simd_size_and_type(*self.tcx);
|
||||
assert!(
|
||||
index < len,
|
||||
"index `{}` is out-of-bounds of vector type `{}` with length `{}`",
|
||||
|
|
|
@ -25,7 +25,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
|
|||
"find_closest_untracked_caller_location: checking frame {:?}",
|
||||
frame.instance
|
||||
);
|
||||
!frame.instance.def.requires_caller_location(self.tcx)
|
||||
!frame.instance.def.requires_caller_location(*self.tcx)
|
||||
})
|
||||
// Assert that there is always such a frame.
|
||||
.unwrap();
|
||||
|
@ -58,7 +58,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
|
|||
let loc_ty = self
|
||||
.tcx
|
||||
.type_of(self.tcx.require_lang_item(PanicLocationLangItem, None))
|
||||
.subst(self.tcx, self.tcx.mk_substs([self.tcx.lifetimes.re_erased.into()].iter()));
|
||||
.subst(*self.tcx, self.tcx.mk_substs([self.tcx.lifetimes.re_erased.into()].iter()));
|
||||
let loc_layout = self.layout_of(loc_ty).unwrap();
|
||||
let location = self.allocate(loc_layout, MemoryKind::CallerLocation);
|
||||
|
||||
|
|
|
@ -471,9 +471,9 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
|
|||
trace!("eval_place_to_op: got {:?}", *op);
|
||||
// Sanity-check the type we ended up with.
|
||||
debug_assert!(mir_assign_valid_types(
|
||||
self.tcx,
|
||||
*self.tcx,
|
||||
self.layout_of(self.subst_from_current_frame_and_normalize_erasing_regions(
|
||||
place.ty(&self.frame().body.local_decls, self.tcx).ty
|
||||
place.ty(&self.frame().body.local_decls, *self.tcx).ty
|
||||
))?,
|
||||
op.layout,
|
||||
));
|
||||
|
@ -554,7 +554,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
|
|||
// documentation).
|
||||
let val_val = M::adjust_global_const(self, val_val)?;
|
||||
// Other cases need layout.
|
||||
let layout = from_known_layout(self.tcx_at(), layout, || self.layout_of(val.ty))?;
|
||||
let layout = from_known_layout(self.tcx, layout, || self.layout_of(val.ty))?;
|
||||
let op = match val_val {
|
||||
ConstValue::ByRef { alloc, offset } => {
|
||||
let id = self.tcx.create_memory_alloc(alloc);
|
||||
|
@ -589,7 +589,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
|
|||
trace!("read_discriminant_value {:#?}", op.layout);
|
||||
|
||||
// Get type and layout of the discriminant.
|
||||
let discr_layout = self.layout_of(op.layout.ty.discriminant_ty(self.tcx))?;
|
||||
let discr_layout = self.layout_of(op.layout.ty.discriminant_ty(*self.tcx))?;
|
||||
trace!("discriminant type: {:?}", discr_layout.ty);
|
||||
|
||||
// We use "discriminant" to refer to the value associated with a particular enum variant.
|
||||
|
@ -601,7 +601,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
|
|||
// rather confusing.
|
||||
let (tag_scalar_layout, tag_kind, tag_index) = match op.layout.variants {
|
||||
Variants::Single { index } => {
|
||||
let discr = match op.layout.ty.discriminant_for_variant(self.tcx, index) {
|
||||
let discr = match op.layout.ty.discriminant_for_variant(*self.tcx, index) {
|
||||
Some(discr) => {
|
||||
// This type actually has discriminants.
|
||||
assert_eq!(discr.ty, discr_layout.ty);
|
||||
|
@ -630,7 +630,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
|
|||
// may be a pointer. This is `tag_val.layout`; we just use it for sanity checks.
|
||||
|
||||
// Get layout for tag.
|
||||
let tag_layout = self.layout_of(tag_scalar_layout.value.to_int_ty(self.tcx))?;
|
||||
let tag_layout = self.layout_of(tag_scalar_layout.value.to_int_ty(*self.tcx))?;
|
||||
|
||||
// Read tag and sanity-check `tag_layout`.
|
||||
let tag_val = self.read_immediate(self.operand_field(op, tag_index)?)?;
|
||||
|
@ -651,12 +651,12 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
|
|||
// Convert discriminant to variant index, and catch invalid discriminants.
|
||||
let index = match op.layout.ty.kind {
|
||||
ty::Adt(adt, _) => {
|
||||
adt.discriminants(self.tcx).find(|(_, var)| var.val == discr_bits)
|
||||
adt.discriminants(*self.tcx).find(|(_, var)| var.val == discr_bits)
|
||||
}
|
||||
ty::Generator(def_id, substs, _) => {
|
||||
let substs = substs.as_generator();
|
||||
substs
|
||||
.discriminants(def_id, self.tcx)
|
||||
.discriminants(def_id, *self.tcx)
|
||||
.find(|(_, var)| var.val == discr_bits)
|
||||
}
|
||||
_ => bug!("tagged layout for non-adt non-generator"),
|
||||
|
|
|
@ -651,9 +651,9 @@ where
|
|||
self.dump_place(place_ty.place);
|
||||
// Sanity-check the type we ended up with.
|
||||
debug_assert!(mir_assign_valid_types(
|
||||
self.tcx,
|
||||
*self.tcx,
|
||||
self.layout_of(self.subst_from_current_frame_and_normalize_erasing_regions(
|
||||
place.ty(&self.frame().body.local_decls, self.tcx).ty
|
||||
place.ty(&self.frame().body.local_decls, *self.tcx).ty
|
||||
))?,
|
||||
place_ty.layout,
|
||||
));
|
||||
|
@ -779,7 +779,7 @@ where
|
|||
None => return Ok(()), // zero-sized access
|
||||
};
|
||||
|
||||
let tcx = self.tcx;
|
||||
let tcx = *self.tcx;
|
||||
// FIXME: We should check that there are dest.layout.size many bytes available in
|
||||
// memory. The code below is not sufficient, with enough padding it might not
|
||||
// cover all the bytes!
|
||||
|
@ -855,7 +855,7 @@ where
|
|||
) -> InterpResult<'tcx> {
|
||||
// We do NOT compare the types for equality, because well-typed code can
|
||||
// actually "transmute" `&mut T` to `&T` in an assignment without a cast.
|
||||
if !mir_assign_valid_types(self.tcx, src.layout, dest.layout) {
|
||||
if !mir_assign_valid_types(*self.tcx, src.layout, dest.layout) {
|
||||
span_bug!(
|
||||
self.cur_span(),
|
||||
"type mismatch when copying!\nsrc: {:?},\ndest: {:?}",
|
||||
|
@ -912,7 +912,7 @@ where
|
|||
src: OpTy<'tcx, M::PointerTag>,
|
||||
dest: PlaceTy<'tcx, M::PointerTag>,
|
||||
) -> InterpResult<'tcx> {
|
||||
if mir_assign_valid_types(self.tcx, src.layout, dest.layout) {
|
||||
if mir_assign_valid_types(*self.tcx, src.layout, dest.layout) {
|
||||
// Fast path: Just use normal `copy_op`
|
||||
return self.copy_op(src, dest);
|
||||
}
|
||||
|
@ -1070,7 +1070,7 @@ where
|
|||
// `TyAndLayout::for_variant()` call earlier already checks the variant is valid.
|
||||
|
||||
let discr_val =
|
||||
dest.layout.ty.discriminant_for_variant(self.tcx, variant_index).unwrap().val;
|
||||
dest.layout.ty.discriminant_for_variant(*self.tcx, variant_index).unwrap().val;
|
||||
|
||||
// raw discriminants for enums are isize or bigger during
|
||||
// their computation, but the in-memory tag is the smallest possible
|
||||
|
@ -1099,7 +1099,7 @@ where
|
|||
.expect("overflow computing relative variant idx");
|
||||
// We need to use machine arithmetic when taking into account `niche_start`:
|
||||
// discr_val = variant_index_relative + niche_start_val
|
||||
let discr_layout = self.layout_of(discr_layout.value.to_int_ty(self.tcx))?;
|
||||
let discr_layout = self.layout_of(discr_layout.value.to_int_ty(*self.tcx))?;
|
||||
let niche_start_val = ImmTy::from_uint(niche_start, discr_layout);
|
||||
let variant_index_relative_val =
|
||||
ImmTy::from_uint(variant_index_relative, discr_layout);
|
||||
|
|
|
@ -69,7 +69,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
|
|||
(fn_val, caller_abi)
|
||||
}
|
||||
ty::FnDef(def_id, substs) => {
|
||||
let sig = func.layout.ty.fn_sig(self.tcx);
|
||||
let sig = func.layout.ty.fn_sig(*self.tcx);
|
||||
(FnVal::Instance(self.resolve(def_id, substs)?), sig.abi())
|
||||
}
|
||||
_ => span_bug!(
|
||||
|
@ -96,7 +96,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
|
|||
let ty = place.layout.ty;
|
||||
trace!("TerminatorKind::drop: {:?}, type {}", location, ty);
|
||||
|
||||
let instance = Instance::resolve_drop_in_place(self.tcx, ty);
|
||||
let instance = Instance::resolve_drop_in_place(*self.tcx, ty);
|
||||
self.drop_in_place(place, instance, target, unwind)?;
|
||||
}
|
||||
|
||||
|
@ -227,9 +227,9 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
|
|||
// ABI check
|
||||
{
|
||||
let callee_abi = {
|
||||
let instance_ty = instance.ty_env(self.tcx, self.param_env);
|
||||
let instance_ty = instance.ty_env(*self.tcx, self.param_env);
|
||||
match instance_ty.kind {
|
||||
ty::FnDef(..) => instance_ty.fn_sig(self.tcx).abi(),
|
||||
ty::FnDef(..) => instance_ty.fn_sig(*self.tcx).abi(),
|
||||
ty::Closure(..) => Abi::RustCall,
|
||||
ty::Generator(..) => Abi::Rust,
|
||||
_ => bug!("unexpected callee ty: {:?}", instance_ty),
|
||||
|
|
|
@ -36,10 +36,10 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
|
|||
}
|
||||
|
||||
let methods = if let Some(poly_trait_ref) = poly_trait_ref {
|
||||
let trait_ref = poly_trait_ref.with_self_ty(self.tcx, ty);
|
||||
let trait_ref = poly_trait_ref.with_self_ty(*self.tcx, ty);
|
||||
let trait_ref = self.tcx.erase_regions(&trait_ref);
|
||||
|
||||
self.tcx_at().vtable_methods(trait_ref)
|
||||
self.tcx.vtable_methods(trait_ref)
|
||||
} else {
|
||||
&[]
|
||||
};
|
||||
|
@ -49,7 +49,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
|
|||
let size = layout.size.bytes();
|
||||
let align = layout.align.abi.bytes();
|
||||
|
||||
let tcx = self.tcx;
|
||||
let tcx = *self.tcx;
|
||||
let ptr_size = self.pointer_size();
|
||||
let ptr_align = tcx.data_layout.pointer_align.abi;
|
||||
// /////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -142,7 +142,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
|
|||
// to determine the type.
|
||||
let drop_instance = self.memory.get_fn(drop_fn)?.as_instance()?;
|
||||
trace!("Found drop fn: {:?}", drop_instance);
|
||||
let fn_sig = drop_instance.ty_env(self.tcx, self.param_env).fn_sig(self.tcx);
|
||||
let fn_sig = drop_instance.ty_env(*self.tcx, self.param_env).fn_sig(*self.tcx);
|
||||
let fn_sig = self.tcx.normalize_erasing_late_bound_regions(self.param_env, &fn_sig);
|
||||
// The drop function takes `*mut T` where `T` is the type being dropped, so get that.
|
||||
let args = fn_sig.inputs();
|
||||
|
|
Loading…
Reference in New Issue