Skip to content

Commit 8f13fb0

Browse files
committed
remove derive(PartialEq,Eq,Hash), fix fmt
1 parent 48ad67e commit 8f13fb0

File tree

4 files changed

+19
-13
lines changed

4 files changed

+19
-13
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
@@ -414,7 +414,11 @@ 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>, MiriAllocBytes>)>,
417+
leaks: Vec<(
418+
AllocId,
419+
MemoryKind<MiriMemoryKind>,
420+
Allocation<Provenance, AllocExtra<'tcx>, MiriAllocBytes>,
421+
)>,
418422
) {
419423
let mut any_pruned = false;
420424
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,14 +74,14 @@ 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;
8081
mod diagnostics;
8182
mod eval;
8283
mod helpers;
8384
mod machine;
84-
mod alloc_bytes;
8585
mod mono_hash_map;
8686
mod operator;
8787
mod provenance_gc;
@@ -104,6 +104,7 @@ pub use crate::shims::time::EvalContextExt as _;
104104
pub use crate::shims::tls::TlsData;
105105

106106
pub use crate::alloc_addresses::{EvalContextExt as _, ProvenanceMode};
107+
pub use crate::alloc_bytes::MiriAllocBytes;
107108
pub use crate::borrow_tracker::stacked_borrows::{
108109
EvalContextExt as _, Item, Permission, Stack, Stacks,
109110
};
@@ -129,7 +130,6 @@ pub use crate::machine::{
129130
AllocExtra, FrameExtra, MiriInterpCx, MiriInterpCxExt, MiriMachine, MiriMemoryKind,
130131
PrimitiveLayouts, Provenance, ProvenanceExtra,
131132
};
132-
pub use crate::alloc_bytes::MiriAllocBytes;
133133
pub use crate::mono_hash_map::MonoHashMap;
134134
pub use crate::operator::EvalContextExt as _;
135135
pub use crate::provenance_gc::{EvalContextExt as _, LiveAllocs, VisitProvenance, VisitWith};

src/machine.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1093,7 +1093,8 @@ impl<'mir, 'tcx> Machine<'mir, 'tcx> for MiriMachine<'mir, 'tcx> {
10931093
id: AllocId,
10941094
alloc: Cow<'b, Allocation>,
10951095
kind: Option<MemoryKind<Self::MemoryKind>>,
1096-
) -> InterpResult<'tcx, Cow<'b, Allocation<Self::Provenance, Self::AllocExtra, Self::Bytes>>> {
1096+
) -> InterpResult<'tcx, Cow<'b, Allocation<Self::Provenance, Self::AllocExtra, Self::Bytes>>>
1097+
{
10971098
let kind = kind.expect("we set our STATIC_KIND so this cannot be None");
10981099
if ecx.machine.tracked_alloc_ids.contains(&id) {
10991100
ecx.emit_diagnostic(NonHaltingDiagnostic::CreatedAlloc(

0 commit comments

Comments
 (0)