Skip to content

Commit 0003957

Browse files
committed
remove derive(PartialEq,Eq,Hash), fix fmt
1 parent 567d18a commit 0003957

File tree

4 files changed

+20
-14
lines changed

4 files changed

+20
-14
lines changed

src/alloc_bytes.rs

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,14 @@
11
use std::alloc;
22
use std::alloc::Layout;
3-
use std::slice;
43
use std::borrow::Cow;
4+
use std::slice;
55

6-
use rustc_target::abi::{Align, Size};
76
use rustc_middle::mir::interpret::AllocBytes;
7+
use rustc_target::abi::{Align, Size};
88

9-
/// The bytes of a Miri allocation, allocated using the size and alignment requested
10-
/// by the interpreted program.
11-
/// This is necessary to interface with native code that exchanges pointers with the
12-
/// interpreted program.
9+
/// Allocation bytes that explicitly handle the layout of the data they're storing.
10+
/// This is necessary to interface with native code that accesses the program store in Miri.
1311
#[derive(Debug)]
14-
#[derive(PartialEq, Eq, Hash)] // TODO Necessary?
1512
pub struct MiriAllocBytes {
1613
/// Stored layout information about the allocation.
1714
layout: alloc::Layout,
@@ -63,7 +60,11 @@ impl MiriAllocBytes {
6360
/// specifically given an allocation function `alloc_fn`.
6461
/// `alloc_fn` is only used if `size != 0`.
6562
/// Returns `Err(layout)` if the allocation function returns a `ptr` that is `ptr.is_null()`.
66-
fn alloc_with(size: usize, align: usize, alloc_fn: impl FnOnce(Layout) -> *mut u8) -> Result<MiriAllocBytes, Layout> {
63+
fn alloc_with(
64+
size: usize,
65+
align: usize,
66+
alloc_fn: impl FnOnce(Layout) -> *mut u8,
67+
) -> Result<MiriAllocBytes, Layout> {
6768
let layout = Layout::from_size_align(size, align).unwrap();
6869
let ptr = if size == 0 {
6970
align as *mut u8 // std::ptr::without_provenance_mut(align) : "use of unstable library feature 'strict_provenance'"
@@ -106,4 +107,4 @@ impl AllocBytes for MiriAllocBytes {
106107
fn as_mut_ptr(&mut self) -> *mut u8 {
107108
self.ptr
108109
}
109-
}
110+
}

src/diagnostics.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -459,7 +459,11 @@ pub fn report_error<'tcx, 'mir>(
459459

460460
pub fn report_leaks<'mir, 'tcx>(
461461
ecx: &InterpCx<'mir, 'tcx, MiriMachine<'mir, 'tcx>>,
462-
leaks: Vec<(AllocId, MemoryKind, Allocation<Provenance, AllocExtra<'tcx>, MiriAllocBytes>)>,
462+
leaks: Vec<(
463+
AllocId,
464+
MemoryKind,
465+
Allocation<Provenance, AllocExtra<'tcx>, MiriAllocBytes>,
466+
)>,
463467
) {
464468
let mut any_pruned = false;
465469
for (id, kind, mut alloc) in leaks {

src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ extern crate rustc_target;
7474
extern crate rustc_driver;
7575

7676
mod alloc_addresses;
77+
mod alloc_bytes;
7778
mod borrow_tracker;
7879
mod clock;
7980
mod concurrency;
@@ -82,7 +83,6 @@ mod eval;
8283
mod helpers;
8384
mod intrinsics;
8485
mod machine;
85-
mod alloc_bytes;
8686
mod mono_hash_map;
8787
mod operator;
8888
mod provenance_gc;
@@ -108,6 +108,7 @@ pub use crate::shims::tls::TlsData;
108108
pub use crate::shims::EmulateItemResult;
109109

110110
pub use crate::alloc_addresses::{EvalContextExt as _, ProvenanceMode};
111+
pub use crate::alloc_bytes::MiriAllocBytes;
111112
pub use crate::borrow_tracker::stacked_borrows::{
112113
EvalContextExt as _, Item, Permission, Stack, Stacks,
113114
};
@@ -135,7 +136,6 @@ pub use crate::machine::{
135136
AllocExtra, FrameExtra, MemoryKind, MiriInterpCx, MiriInterpCxExt, MiriMachine, MiriMemoryKind,
136137
PrimitiveLayouts, Provenance, ProvenanceExtra,
137138
};
138-
pub use crate::alloc_bytes::MiriAllocBytes;
139139
pub use crate::mono_hash_map::MonoHashMap;
140140
pub use crate::operator::EvalContextExt as _;
141141
pub use crate::provenance_gc::{EvalContextExt as _, LiveAllocs, VisitProvenance, VisitWith};

src/machine.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1088,8 +1088,9 @@ impl<'mir, 'tcx> Machine<'mir, 'tcx> for MiriMachine<'mir, 'tcx> {
10881088
id: AllocId,
10891089
alloc: Cow<'b, Allocation>,
10901090
kind: Option<MemoryKind>,
1091-
) -> InterpResult<'tcx, Cow<'b, Allocation<Self::Provenance, Self::AllocExtra, Self::Bytes>>> {
1092-
let kind = kind.expect("we set our GLOBAL_KIND so this cannot be None");
1091+
) -> InterpResult<'tcx, Cow<'b, Allocation<Self::Provenance, Self::AllocExtra, Self::Bytes>>>
1092+
{
1093+
let kind = kind.expect("we set our STATIC_KIND so this cannot be None");
10931094
if ecx.machine.tracked_alloc_ids.contains(&id) {
10941095
ecx.emit_diagnostic(NonHaltingDiagnostic::CreatedAlloc(
10951096
id,

0 commit comments

Comments
 (0)