Skip to content

Commit 4cbe1f4

Browse files
committed
Auto merge of #1402 - rust-lang:alloc_map_unlock, r=RalfJung
Update to rustc changes changes needed once rust-lang/rust#71508 gets merged
2 parents 8a6396f + 4f06197 commit 4cbe1f4

File tree

4 files changed

+7
-8
lines changed

4 files changed

+7
-8
lines changed

rust-version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0f9088f9610618e724cfc0cf2ba3721918be5ec9
1+
6f5c7827b71d1e1e4831fa7522e49acaf2a9e44e

src/machine.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -427,7 +427,7 @@ impl<'mir, 'tcx> Machine<'mir, 'tcx> for Evaluator<'mir, 'tcx> {
427427
fn canonical_alloc_id(mem: &Memory<'mir, 'tcx, Self>, id: AllocId) -> AllocId {
428428
let tcx = mem.tcx;
429429
// Figure out if this is an extern static, and if yes, which one.
430-
let def_id = match tcx.alloc_map.lock().get(id) {
430+
let def_id = match tcx.get_global_alloc(id) {
431431
Some(GlobalAlloc::Static(def_id)) if tcx.is_foreign_item(def_id) => def_id,
432432
_ => {
433433
// No need to canonicalize anything.
@@ -494,7 +494,7 @@ impl<'mir, 'tcx> Machine<'mir, 'tcx> for Evaluator<'mir, 'tcx> {
494494
if Some(id) == memory_extra.tracked_alloc_id {
495495
register_diagnostic(NonHaltingDiagnostic::FreedAlloc(id));
496496
}
497-
497+
498498
Ok(())
499499
}
500500

src/thread.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -428,7 +428,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
428428
match *val {
429429
mir::interpret::ConstValue::Scalar(Scalar::Ptr(ref mut ptr)) => {
430430
let alloc_id = ptr.alloc_id;
431-
let alloc = this.tcx.alloc_map.lock().get(alloc_id);
431+
let alloc = this.tcx.get_global_alloc(alloc_id);
432432
let tcx = this.tcx;
433433
let is_thread_local = |def_id| {
434434
tcx.codegen_fn_attrs(def_id).flags.contains(CodegenFnAttrFlags::THREAD_LOCAL)
@@ -489,13 +489,12 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
489489
})?;
490490
let id = raw_const.alloc_id;
491491
// Extract the allocation from the query result.
492-
let mut alloc_map = tcx.alloc_map.lock();
493-
let allocation = alloc_map.unwrap_memory(id);
492+
let allocation = tcx.global_alloc(id).unwrap_memory();
494493
// Create a new allocation id for the same allocation in this hacky
495494
// way. Internally, `alloc_map` deduplicates allocations, but this
496495
// is fine because Miri will make a copy before a first mutable
497496
// access.
498-
let new_alloc_id = alloc_map.create_memory_alloc(allocation);
497+
let new_alloc_id = tcx.create_memory_alloc(allocation);
499498
this.machine.threads.set_thread_local_alloc_id(def_id, new_alloc_id);
500499
Ok(new_alloc_id)
501500
}

tests/compile-fail/validity/invalid_wide_raw.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@ fn main() {
66
struct S {
77
x: * mut dyn T
88
}
9-
dbg!(S { x: unsafe { std::mem::transmute((0usize, 0usize)) } }); //~ ERROR: encountered dangling vtable pointer
9+
dbg!(S { x: unsafe { std::mem::transmute((0usize, 0usize)) } }); //~ ERROR: encountered dangling vtable pointer in wide pointer
1010
}

0 commit comments

Comments
 (0)