Skip to content

Commit 0e034ff

Browse files
authored
Unrolled build for rust-lang#124018
Rollup merge of rust-lang#124018 - RalfJung:dealloc-memory-kind, r=oli-obk interpret: pass MemoryKind to before_memory_deallocation This will be needed for rust-lang/miri#3475. r? ``@oli-obk``
2 parents 1dea922 + 18bfca5 commit 0e034ff

File tree

10 files changed

+21
-18
lines changed

10 files changed

+21
-18
lines changed

compiler/rustc_const_eval/src/interpret/machine.rs

+1
Original file line numberDiff line numberDiff line change
@@ -427,6 +427,7 @@ pub trait Machine<'mir, 'tcx: 'mir>: Sized {
427427
_prov: (AllocId, Self::ProvenanceExtra),
428428
_size: Size,
429429
_align: Align,
430+
_kind: MemoryKind<Self::MemoryKind>,
430431
) -> InterpResult<'tcx> {
431432
Ok(())
432433
}

compiler/rustc_const_eval/src/interpret/memory.rs

+1
Original file line numberDiff line numberDiff line change
@@ -355,6 +355,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
355355
(alloc_id, prov),
356356
size,
357357
alloc.align,
358+
kind,
358359
)?;
359360

360361
// Don't forget to remember size and align of this now-dead allocation

src/tools/miri/src/borrow_tracker/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ impl GlobalStateInner {
260260
&mut self,
261261
id: AllocId,
262262
alloc_size: Size,
263-
kind: MemoryKind<machine::MiriMemoryKind>,
263+
kind: MemoryKind,
264264
machine: &MiriMachine<'_, '_>,
265265
) -> AllocState {
266266
match self.borrow_tracker_method {

src/tools/miri/src/borrow_tracker/stacked_borrows/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -509,7 +509,7 @@ impl Stacks {
509509
id: AllocId,
510510
size: Size,
511511
state: &mut GlobalStateInner,
512-
kind: MemoryKind<MiriMemoryKind>,
512+
kind: MemoryKind,
513513
machine: &MiriMachine<'_, '_>,
514514
) -> Self {
515515
let (base_tag, perm) = match kind {

src/tools/miri/src/borrow_tracker/tree_borrows/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ impl<'tcx> Tree {
3434
id: AllocId,
3535
size: Size,
3636
state: &mut GlobalStateInner,
37-
_kind: MemoryKind<machine::MiriMemoryKind>,
37+
_kind: MemoryKind,
3838
machine: &MiriMachine<'_, 'tcx>,
3939
) -> Self {
4040
let tag = state.base_ptr_tag(id, machine); // Fresh tag for the root

src/tools/miri/src/concurrency/data_race.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -844,7 +844,7 @@ impl VClockAlloc {
844844
global: &GlobalState,
845845
thread_mgr: &ThreadManager<'_, '_>,
846846
len: Size,
847-
kind: MemoryKind<MiriMemoryKind>,
847+
kind: MemoryKind,
848848
current_span: Span,
849849
) -> VClockAlloc {
850850
let (alloc_timestamp, alloc_index) = match kind {

src/tools/miri/src/diagnostics.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ pub enum NonHaltingDiagnostic {
115115
/// This `Item` was popped from the borrow stack. The string explains the reason.
116116
PoppedPointerTag(Item, String),
117117
CreatedCallId(CallId),
118-
CreatedAlloc(AllocId, Size, Align, MemoryKind<MiriMemoryKind>),
118+
CreatedAlloc(AllocId, Size, Align, MemoryKind),
119119
FreedAlloc(AllocId),
120120
AccessedAlloc(AllocId, AccessKind),
121121
RejectedIsolatedOp(String),
@@ -414,7 +414,7 @@ pub fn report_error<'tcx, 'mir>(
414414

415415
pub fn report_leaks<'mir, 'tcx>(
416416
ecx: &InterpCx<'mir, 'tcx, MiriMachine<'mir, 'tcx>>,
417-
leaks: Vec<(AllocId, MemoryKind<MiriMemoryKind>, Allocation<Provenance, AllocExtra<'tcx>>)>,
417+
leaks: Vec<(AllocId, MemoryKind, Allocation<Provenance, AllocExtra<'tcx>>)>,
418418
) {
419419
let mut any_pruned = false;
420420
for (id, kind, mut alloc) in leaks {

src/tools/miri/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ pub use crate::eval::{
125125
};
126126
pub use crate::helpers::{AccessKind, EvalContextExt as _};
127127
pub use crate::machine::{
128-
AllocExtra, FrameExtra, MiriInterpCx, MiriInterpCxExt, MiriMachine, MiriMemoryKind,
128+
AllocExtra, FrameExtra, MemoryKind, MiriInterpCx, MiriInterpCxExt, MiriMachine, MiriMemoryKind,
129129
PrimitiveLayouts, Provenance, ProvenanceExtra,
130130
};
131131
pub use crate::mono_hash_map::MonoHashMap;

src/tools/miri/src/machine.rs

+8-7
Original file line numberDiff line numberDiff line change
@@ -135,9 +135,9 @@ pub enum MiriMemoryKind {
135135
Mmap,
136136
}
137137

138-
impl From<MiriMemoryKind> for MemoryKind<MiriMemoryKind> {
138+
impl From<MiriMemoryKind> for MemoryKind {
139139
#[inline(always)]
140-
fn from(kind: MiriMemoryKind) -> MemoryKind<MiriMemoryKind> {
140+
fn from(kind: MiriMemoryKind) -> MemoryKind {
141141
MemoryKind::Machine(kind)
142142
}
143143
}
@@ -185,6 +185,8 @@ impl fmt::Display for MiriMemoryKind {
185185
}
186186
}
187187

188+
pub type MemoryKind = interpret::MemoryKind<MiriMemoryKind>;
189+
188190
/// Pointer provenance.
189191
#[derive(Clone, Copy)]
190192
pub enum Provenance {
@@ -863,10 +865,8 @@ impl<'mir, 'tcx> Machine<'mir, 'tcx> for MiriMachine<'mir, 'tcx> {
863865
type ProvenanceExtra = ProvenanceExtra;
864866
type Bytes = Box<[u8]>;
865867

866-
type MemoryMap = MonoHashMap<
867-
AllocId,
868-
(MemoryKind<MiriMemoryKind>, Allocation<Provenance, Self::AllocExtra, Self::Bytes>),
869-
>;
868+
type MemoryMap =
869+
MonoHashMap<AllocId, (MemoryKind, Allocation<Provenance, Self::AllocExtra, Self::Bytes>)>;
870870

871871
const GLOBAL_KIND: Option<MiriMemoryKind> = Some(MiriMemoryKind::Global);
872872

@@ -1088,7 +1088,7 @@ impl<'mir, 'tcx> Machine<'mir, 'tcx> for MiriMachine<'mir, 'tcx> {
10881088
ecx: &MiriInterpCx<'mir, 'tcx>,
10891089
id: AllocId,
10901090
alloc: Cow<'b, Allocation>,
1091-
kind: Option<MemoryKind<Self::MemoryKind>>,
1091+
kind: Option<MemoryKind>,
10921092
) -> InterpResult<'tcx, Cow<'b, Allocation<Self::Provenance, Self::AllocExtra>>> {
10931093
let kind = kind.expect("we set our STATIC_KIND so this cannot be None");
10941094
if ecx.machine.tracked_alloc_ids.contains(&id) {
@@ -1280,6 +1280,7 @@ impl<'mir, 'tcx> Machine<'mir, 'tcx> for MiriMachine<'mir, 'tcx> {
12801280
(alloc_id, prove_extra): (AllocId, Self::ProvenanceExtra),
12811281
size: Size,
12821282
align: Align,
1283+
_kind: MemoryKind,
12831284
) -> InterpResult<'tcx> {
12841285
if machine.tracked_alloc_ids.contains(&alloc_id) {
12851286
machine.emit_diagnostic(NonHaltingDiagnostic::FreedAlloc(alloc_id));

src/tools/miri/src/shims/os_str.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
136136
fn alloc_os_str_as_c_str(
137137
&mut self,
138138
os_str: &OsStr,
139-
memkind: MemoryKind<MiriMemoryKind>,
139+
memkind: MemoryKind,
140140
) -> InterpResult<'tcx, Pointer<Option<Provenance>>> {
141141
let size = u64::try_from(os_str.len()).unwrap().checked_add(1).unwrap(); // Make space for `0` terminator.
142142
let this = self.eval_context_mut();
@@ -152,7 +152,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
152152
fn alloc_os_str_as_wide_str(
153153
&mut self,
154154
os_str: &OsStr,
155-
memkind: MemoryKind<MiriMemoryKind>,
155+
memkind: MemoryKind,
156156
) -> InterpResult<'tcx, Pointer<Option<Provenance>>> {
157157
let size = u64::try_from(os_str.len()).unwrap().checked_add(1).unwrap(); // Make space for `0x0000` terminator.
158158
let this = self.eval_context_mut();
@@ -229,7 +229,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
229229
fn alloc_path_as_c_str(
230230
&mut self,
231231
path: &Path,
232-
memkind: MemoryKind<MiriMemoryKind>,
232+
memkind: MemoryKind,
233233
) -> InterpResult<'tcx, Pointer<Option<Provenance>>> {
234234
let this = self.eval_context_mut();
235235
let os_str =
@@ -242,7 +242,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
242242
fn alloc_path_as_wide_str(
243243
&mut self,
244244
path: &Path,
245-
memkind: MemoryKind<MiriMemoryKind>,
245+
memkind: MemoryKind,
246246
) -> InterpResult<'tcx, Pointer<Option<Provenance>>> {
247247
let this = self.eval_context_mut();
248248
let os_str =

0 commit comments

Comments
 (0)