Skip to content

Commit 8c71d33

Browse files
committed
Auto merge of #131672 - matthiaskrgr:rollup-gyzysj4, r=matthiaskrgr
Rollup of 8 pull requests Successful merges: - #128967 (std::fs::get_path freebsd update.) - #130629 (core/net: add Ipv[46]Addr::from_octets, Ipv6Addr::from_segments.) - #131274 (library: Const-stabilize `MaybeUninit::assume_init_mut`) - #131473 (compiler: `{TyAnd,}Layout` comes home) - #131533 (emscripten: Use the latest emsdk 3.1.68) - #131593 (miri: avoid cloning AllocExtra) - #131616 (merge const_ipv4 / const_ipv6 feature gate into 'ip' feature gate) - #131660 (Also use outermost const-anon for impl items in `non_local_defs` lint) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 70a31c0 + 72437b1 commit 8c71d33

File tree

3 files changed

+12
-4
lines changed

3 files changed

+12
-4
lines changed

src/diagnostics.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -473,14 +473,14 @@ pub fn report_leaks<'tcx>(
473473
leaks: Vec<(AllocId, MemoryKind, Allocation<Provenance, AllocExtra<'tcx>, MiriAllocBytes>)>,
474474
) {
475475
let mut any_pruned = false;
476-
for (id, kind, mut alloc) in leaks {
476+
for (id, kind, alloc) in leaks {
477477
let mut title = format!(
478478
"memory leaked: {id:?} ({}, size: {:?}, align: {:?})",
479479
kind,
480480
alloc.size().bytes(),
481481
alloc.align.bytes()
482482
);
483-
let Some(backtrace) = alloc.extra.backtrace.take() else {
483+
let Some(backtrace) = alloc.extra.backtrace else {
484484
ecx.tcx.dcx().err(title);
485485
continue;
486486
};

src/eval.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -476,7 +476,7 @@ pub fn eval_entry<'tcx>(
476476
}
477477
// Check for memory leaks.
478478
info!("Additional static roots: {:?}", ecx.machine.static_roots);
479-
let leaks = ecx.find_leaked_allocations(&ecx.machine.static_roots);
479+
let leaks = ecx.take_leaked_allocations(|ecx| &ecx.machine.static_roots);
480480
if !leaks.is_empty() {
481481
report_leaks(&ecx, leaks);
482482
tcx.dcx().note("set `MIRIFLAGS=-Zmiri-ignore-leaks` to disable this check");

src/machine.rs

+9-1
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@ impl ProvenanceExtra {
321321
}
322322

323323
/// Extra per-allocation data
324-
#[derive(Debug, Clone)]
324+
#[derive(Debug)]
325325
pub struct AllocExtra<'tcx> {
326326
/// Global state of the borrow tracker, if enabled.
327327
pub borrow_tracker: Option<borrow_tracker::AllocState>,
@@ -338,6 +338,14 @@ pub struct AllocExtra<'tcx> {
338338
pub backtrace: Option<Vec<FrameInfo<'tcx>>>,
339339
}
340340

341+
// We need a `Clone` impl because the machine passes `Allocation` through `Cow`...
342+
// but that should never end up actually cloning our `AllocExtra`.
343+
impl<'tcx> Clone for AllocExtra<'tcx> {
344+
fn clone(&self) -> Self {
345+
panic!("our allocations should never be cloned");
346+
}
347+
}
348+
341349
impl VisitProvenance for AllocExtra<'_> {
342350
fn visit_provenance(&self, visit: &mut VisitWith<'_>) {
343351
let AllocExtra { borrow_tracker, data_race, weak_memory, backtrace: _ } = self;

0 commit comments

Comments
 (0)