Skip to content

Commit 871513d

Browse files
committed
make miri memory TyCtxtAt a TyCtxt
1 parent e91bf6c commit 871513d

File tree

2 files changed

+11
-12
lines changed

2 files changed

+11
-12
lines changed

src/librustc_mir/interpret/eval_context.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -301,15 +301,14 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
301301
machine,
302302
tcx,
303303
param_env,
304-
memory: Memory::new(tcx, memory_extra),
304+
memory: Memory::new(*tcx, memory_extra),
305305
vtables: FxHashMap::default(),
306306
}
307307
}
308308

309309
#[inline(always)]
310310
pub fn set_span(&mut self, span: Span) {
311311
self.tcx.span = span;
312-
self.memory.tcx.span = span;
313312
}
314313

315314
#[inline(always)]

src/librustc_mir/interpret/memory.rs

+10-10
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use std::ptr;
1414

1515
use rustc_ast::ast::Mutability;
1616
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
17-
use rustc_middle::ty::{self, query::TyCtxtAt, Instance, ParamEnv};
17+
use rustc_middle::ty::{self, TyCtxt, Instance, ParamEnv};
1818
use rustc_target::abi::{Align, HasDataLayout, Size, TargetDataLayout};
1919

2020
use super::{
@@ -115,7 +115,7 @@ pub struct Memory<'mir, 'tcx, M: Machine<'mir, 'tcx>> {
115115
pub extra: M::MemoryExtra,
116116

117117
/// Lets us implement `HasDataLayout`, which is awfully convenient.
118-
pub tcx: TyCtxtAt<'tcx>,
118+
pub tcx: TyCtxt<'tcx>,
119119
}
120120

121121
impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> HasDataLayout for Memory<'mir, 'tcx, M> {
@@ -126,7 +126,7 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> HasDataLayout for Memory<'mir, 'tcx, M>
126126
}
127127

128128
impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'mir, 'tcx, M> {
129-
pub fn new(tcx: TyCtxtAt<'tcx>, extra: M::MemoryExtra) -> Self {
129+
pub fn new(tcx: TyCtxt<'tcx>, extra: M::MemoryExtra) -> Self {
130130
Memory {
131131
alloc_map: M::MemoryMap::default(),
132132
extra_fn_ptr_map: FxHashMap::default(),
@@ -425,7 +425,7 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'mir, 'tcx, M> {
425425
/// `M::tag_allocation`.
426426
fn get_global_alloc(
427427
memory_extra: &M::MemoryExtra,
428-
tcx: TyCtxtAt<'tcx>,
428+
tcx: TyCtxt<'tcx>,
429429
id: AllocId,
430430
is_write: bool,
431431
) -> InterpResult<'tcx, Cow<'tcx, Allocation<M::PointerTag, M::AllocExtra>>> {
@@ -455,7 +455,7 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'mir, 'tcx, M> {
455455
throw_unsup!(ReadForeignStatic(def_id))
456456
}
457457
trace!("get_global_alloc: Need to compute {:?}", def_id);
458-
let instance = Instance::mono(tcx.tcx, def_id);
458+
let instance = Instance::mono(tcx, def_id);
459459
let gid = GlobalId { instance, promoted: None };
460460
// Use the raw query here to break validation cycles. Later uses of the static
461461
// will call the full query anyway.
@@ -664,14 +664,14 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'mir, 'tcx, M> {
664664
pub fn dump_allocs(&self, mut allocs: Vec<AllocId>) {
665665
// Cannot be a closure because it is generic in `Tag`, `Extra`.
666666
fn write_allocation_track_relocs<'tcx, Tag: Copy + fmt::Debug, Extra>(
667-
tcx: TyCtxtAt<'tcx>,
667+
tcx: TyCtxt<'tcx>,
668668
allocs_to_print: &mut VecDeque<AllocId>,
669669
alloc: &Allocation<Tag, Extra>,
670670
) {
671671
for &(_, target_id) in alloc.relocations().values() {
672672
allocs_to_print.push_back(target_id);
673673
}
674-
pretty::write_allocation(tcx.tcx, alloc, &mut std::io::stderr()).unwrap();
674+
pretty::write_allocation(tcx, alloc, &mut std::io::stderr()).unwrap();
675675
}
676676

677677
allocs.sort();
@@ -820,7 +820,7 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'mir, 'tcx, M> {
820820
return Ok(());
821821
}
822822
};
823-
let tcx = self.tcx.tcx;
823+
let tcx = self.tcx;
824824
self.get_raw_mut(ptr.alloc_id)?.write_bytes(&tcx, ptr, src)
825825
}
826826

@@ -846,7 +846,7 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'mir, 'tcx, M> {
846846
return Ok(());
847847
}
848848
};
849-
let tcx = self.tcx.tcx;
849+
let tcx = self.tcx;
850850
let allocation = self.get_raw_mut(ptr.alloc_id)?;
851851

852852
for idx in 0..len {
@@ -888,7 +888,7 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'mir, 'tcx, M> {
888888
let relocations =
889889
self.get_raw(src.alloc_id)?.prepare_relocation_copy(self, src, size, dest, length);
890890

891-
let tcx = self.tcx.tcx;
891+
let tcx = self.tcx;
892892

893893
// This checks relocation edges on the src.
894894
let src_bytes =

0 commit comments

Comments
 (0)