Skip to content

Commit b282c28

Browse files
committed
Auto merge of #141605 - jieyouxu:rollup-3gjqh5l, r=jieyouxu
Rollup of 10 pull requests Successful merges: - rust-lang/rust#140898 (minor improvements on running miri) - rust-lang/rust#141392 (Avoid obligation construction dance with query region constraints) - rust-lang/rust#141431 (Emit dummy open drop for unsafe binder) - rust-lang/rust#141433 (Properly analyze captures from unsafe binders) - rust-lang/rust#141439 (Deduplicate dyn compatibility violations due to coercion) - rust-lang/rust#141449 (further deduplicate ast visitor code) - rust-lang/rust#141513 (interpret: add allocation parameters to `AllocBytes`) - rust-lang/rust#141516 (speed up charsearcher for ascii chars) - rust-lang/rust#141526 (add a dedicated section for compiler environment variables in the unstable book) - rust-lang/rust#141550 (Fix `unused_braces` lint suggestion when encountering attributes) r? `@ghost` `@rustbot` modify labels: rollup
2 parents a2cb75b + 8775dce commit b282c28

File tree

4 files changed

+13
-7
lines changed

4 files changed

+13
-7
lines changed

src/alloc_addresses/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ trait EvalContextExtPriv<'tcx>: crate::MiriInterpCxExt<'tcx> {
139139
AllocKind::LiveData => {
140140
if memory_kind == MiriMemoryKind::Global.into() {
141141
// For new global allocations, we always pre-allocate the memory to be able use the machine address directly.
142-
let prepared_bytes = MiriAllocBytes::zeroed(info.size, info.align)
142+
let prepared_bytes = MiriAllocBytes::zeroed(info.size, info.align, ())
143143
.unwrap_or_else(|| {
144144
panic!("Miri ran out of memory: cannot create allocation of {size:?} bytes", size = info.size)
145145
});
@@ -159,7 +159,7 @@ trait EvalContextExtPriv<'tcx>: crate::MiriInterpCxExt<'tcx> {
159159
AllocKind::Function | AllocKind::VTable => {
160160
// Allocate some dummy memory to get a unique address for this function/vtable.
161161
let alloc_bytes =
162-
MiriAllocBytes::from_bytes(&[0u8; 1], Align::from_bytes(1).unwrap());
162+
MiriAllocBytes::from_bytes(&[0u8; 1], Align::from_bytes(1).unwrap(), ());
163163
let ptr = alloc_bytes.as_ptr();
164164
// Leak the underlying memory to ensure it remains unique.
165165
std::mem::forget(alloc_bytes);
@@ -429,7 +429,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
429429
prepared_alloc_bytes.copy_from_slice(bytes);
430430
interp_ok(prepared_alloc_bytes)
431431
} else {
432-
interp_ok(MiriAllocBytes::from_bytes(std::borrow::Cow::Borrowed(bytes), align))
432+
interp_ok(MiriAllocBytes::from_bytes(std::borrow::Cow::Borrowed(bytes), align, ()))
433433
}
434434
}
435435

src/alloc_bytes.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ impl Clone for MiriAllocBytes {
2424
fn clone(&self) -> Self {
2525
let bytes: Cow<'_, [u8]> = Cow::Borrowed(self);
2626
let align = Align::from_bytes(self.layout.align().to_u64()).unwrap();
27-
MiriAllocBytes::from_bytes(bytes, align)
27+
MiriAllocBytes::from_bytes(bytes, align, ())
2828
}
2929
}
3030

@@ -86,7 +86,10 @@ impl MiriAllocBytes {
8686
}
8787

8888
impl AllocBytes for MiriAllocBytes {
89-
fn from_bytes<'a>(slice: impl Into<Cow<'a, [u8]>>, align: Align) -> Self {
89+
/// Placeholder!
90+
type AllocParams = ();
91+
92+
fn from_bytes<'a>(slice: impl Into<Cow<'a, [u8]>>, align: Align, _params: ()) -> Self {
9093
let slice = slice.into();
9194
let size = slice.len();
9295
let align = align.bytes();
@@ -102,7 +105,7 @@ impl AllocBytes for MiriAllocBytes {
102105
alloc_bytes
103106
}
104107

105-
fn zeroed(size: Size, align: Align) -> Option<Self> {
108+
fn zeroed(size: Size, align: Align, _params: ()) -> Option<Self> {
106109
let size = size.bytes();
107110
let align = align.bytes();
108111
// SAFETY: `alloc_fn` will only be used with `size != 0`.

src/concurrency/thread.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -902,7 +902,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
902902
let mut alloc = alloc.inner().adjust_from_tcx(
903903
&this.tcx,
904904
|bytes, align| {
905-
interp_ok(MiriAllocBytes::from_bytes(std::borrow::Cow::Borrowed(bytes), align))
905+
interp_ok(MiriAllocBytes::from_bytes(std::borrow::Cow::Borrowed(bytes), align, ()))
906906
},
907907
|ptr| this.global_root_pointer(ptr),
908908
)?;

src/machine.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1803,6 +1803,9 @@ impl<'tcx> Machine<'tcx> for MiriMachine<'tcx> {
18031803
) -> Cow<'e, RangeSet> {
18041804
Cow::Borrowed(ecx.machine.union_data_ranges.entry(ty).or_insert_with(compute_range))
18051805
}
1806+
1807+
/// Placeholder!
1808+
fn get_default_alloc_params(&self) -> <Self::Bytes as AllocBytes>::AllocParams { () }
18061809
}
18071810

18081811
/// Trait for callbacks handling asynchronous machine operations.

0 commit comments

Comments
 (0)