Skip to content

Commit 79292a2

Browse files
authored
Merge pull request #4226 from rust-lang/rustup-2025-03-14
Automatic Rustup
2 parents 578098f + f787255 commit 79292a2

32 files changed

+92
-82
lines changed

rust-version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
90384941aae4ea38de00e4702b50757e9b882a19
1+
addae0705c7cf5b2f2ed7faeec026c894f497b3d

src/alloc_addresses/mod.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -200,8 +200,8 @@ trait EvalContextExtPriv<'tcx>: crate::MiriInterpCxExt<'tcx> {
200200
}
201201
AllocKind::Dead => unreachable!(),
202202
};
203-
// Ensure this pointer's provenance is exposed, so that it can be used by FFI code.
204-
return interp_ok(base_ptr.expose_provenance().try_into().unwrap());
203+
// We don't have to expose this pointer yet, we do that in `prepare_for_native_call`.
204+
return interp_ok(base_ptr.addr().try_into().unwrap());
205205
}
206206
// We are not in native lib mode, so we control the addresses ourselves.
207207
if let Some((reuse_addr, clock)) = global_state.reuse.take_addr(
@@ -379,7 +379,6 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
379379
fn get_global_alloc_bytes(
380380
&self,
381381
id: AllocId,
382-
kind: MemoryKind,
383382
bytes: &[u8],
384383
align: Align,
385384
) -> InterpResult<'tcx, MiriAllocBytes> {
@@ -389,7 +388,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
389388
// In native lib mode, MiriAllocBytes for global allocations are handled via `prepared_alloc_bytes`.
390389
// This additional call ensures that some `MiriAllocBytes` are always prepared, just in case
391390
// this function gets called before the first time `addr_from_alloc_id` gets called.
392-
this.addr_from_alloc_id(id, kind)?;
391+
this.addr_from_alloc_id(id, MiriMemoryKind::Global.into())?;
393392
// The memory we need here will have already been allocated during an earlier call to
394393
// `addr_from_alloc_id` for this allocation. So don't create a new `MiriAllocBytes` here, instead
395394
// fetch the previously prepared bytes from `prepared_alloc_bytes`.

src/machine.rs

Lines changed: 59 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -814,6 +814,59 @@ impl<'tcx> MiriMachine<'tcx> {
814814
.and_then(|(_allocated, deallocated)| *deallocated)
815815
.map(Span::data)
816816
}
817+
818+
fn init_allocation(
819+
ecx: &MiriInterpCx<'tcx>,
820+
id: AllocId,
821+
kind: MemoryKind,
822+
size: Size,
823+
align: Align,
824+
) -> InterpResult<'tcx, AllocExtra<'tcx>> {
825+
if ecx.machine.tracked_alloc_ids.contains(&id) {
826+
ecx.emit_diagnostic(NonHaltingDiagnostic::CreatedAlloc(id, size, align, kind));
827+
}
828+
829+
let borrow_tracker = ecx
830+
.machine
831+
.borrow_tracker
832+
.as_ref()
833+
.map(|bt| bt.borrow_mut().new_allocation(id, size, kind, &ecx.machine));
834+
835+
let data_race = ecx.machine.data_race.as_ref().map(|data_race| {
836+
data_race::AllocState::new_allocation(
837+
data_race,
838+
&ecx.machine.threads,
839+
size,
840+
kind,
841+
ecx.machine.current_span(),
842+
)
843+
});
844+
let weak_memory = ecx.machine.weak_memory.then(weak_memory::AllocState::new_allocation);
845+
846+
// If an allocation is leaked, we want to report a backtrace to indicate where it was
847+
// allocated. We don't need to record a backtrace for allocations which are allowed to
848+
// leak.
849+
let backtrace = if kind.may_leak() || !ecx.machine.collect_leak_backtraces {
850+
None
851+
} else {
852+
Some(ecx.generate_stacktrace())
853+
};
854+
855+
if matches!(kind, MemoryKind::Machine(kind) if kind.should_save_allocation_span()) {
856+
ecx.machine
857+
.allocation_spans
858+
.borrow_mut()
859+
.insert(id, (ecx.machine.current_span(), None));
860+
}
861+
862+
interp_ok(AllocExtra {
863+
borrow_tracker,
864+
data_race,
865+
weak_memory,
866+
backtrace,
867+
sync: FxHashMap::default(),
868+
})
869+
}
817870
}
818871

819872
impl VisitProvenance for MiriMachine<'_> {
@@ -1200,57 +1253,15 @@ impl<'tcx> Machine<'tcx> for MiriMachine<'tcx> {
12001253
}
12011254
}
12021255

1203-
fn init_alloc_extra(
1256+
fn init_local_allocation(
12041257
ecx: &MiriInterpCx<'tcx>,
12051258
id: AllocId,
12061259
kind: MemoryKind,
12071260
size: Size,
12081261
align: Align,
12091262
) -> InterpResult<'tcx, Self::AllocExtra> {
1210-
if ecx.machine.tracked_alloc_ids.contains(&id) {
1211-
ecx.emit_diagnostic(NonHaltingDiagnostic::CreatedAlloc(id, size, align, kind));
1212-
}
1213-
1214-
let borrow_tracker = ecx
1215-
.machine
1216-
.borrow_tracker
1217-
.as_ref()
1218-
.map(|bt| bt.borrow_mut().new_allocation(id, size, kind, &ecx.machine));
1219-
1220-
let data_race = ecx.machine.data_race.as_ref().map(|data_race| {
1221-
data_race::AllocState::new_allocation(
1222-
data_race,
1223-
&ecx.machine.threads,
1224-
size,
1225-
kind,
1226-
ecx.machine.current_span(),
1227-
)
1228-
});
1229-
let weak_memory = ecx.machine.weak_memory.then(weak_memory::AllocState::new_allocation);
1230-
1231-
// If an allocation is leaked, we want to report a backtrace to indicate where it was
1232-
// allocated. We don't need to record a backtrace for allocations which are allowed to
1233-
// leak.
1234-
let backtrace = if kind.may_leak() || !ecx.machine.collect_leak_backtraces {
1235-
None
1236-
} else {
1237-
Some(ecx.generate_stacktrace())
1238-
};
1239-
1240-
if matches!(kind, MemoryKind::Machine(kind) if kind.should_save_allocation_span()) {
1241-
ecx.machine
1242-
.allocation_spans
1243-
.borrow_mut()
1244-
.insert(id, (ecx.machine.current_span(), None));
1245-
}
1246-
1247-
interp_ok(AllocExtra {
1248-
borrow_tracker,
1249-
data_race,
1250-
weak_memory,
1251-
backtrace,
1252-
sync: FxHashMap::default(),
1253-
})
1263+
assert!(kind != MiriMemoryKind::Global.into());
1264+
MiriMachine::init_allocation(ecx, id, kind, size, align)
12541265
}
12551266

12561267
fn adjust_alloc_root_pointer(
@@ -1340,13 +1351,13 @@ impl<'tcx> Machine<'tcx> for MiriMachine<'tcx> {
13401351
alloc: &'b Allocation,
13411352
) -> InterpResult<'tcx, Cow<'b, Allocation<Self::Provenance, Self::AllocExtra, Self::Bytes>>>
13421353
{
1343-
let kind = Self::GLOBAL_KIND.unwrap().into();
13441354
let alloc = alloc.adjust_from_tcx(
13451355
&ecx.tcx,
1346-
|bytes, align| ecx.get_global_alloc_bytes(id, kind, bytes, align),
1356+
|bytes, align| ecx.get_global_alloc_bytes(id, bytes, align),
13471357
|ptr| ecx.global_root_pointer(ptr),
13481358
)?;
1349-
let extra = Self::init_alloc_extra(ecx, id, kind, alloc.size(), alloc.align)?;
1359+
let kind = MiriMemoryKind::Global.into();
1360+
let extra = MiriMachine::init_allocation(ecx, id, kind, alloc.size(), alloc.align)?;
13501361
interp_ok(Cow::Owned(alloc.with_extra(extra)))
13511362
}
13521363

src/shims/native_lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ fn imm_to_carg<'tcx>(v: &ImmTy<'tcx>, cx: &impl HasDataLayout) -> InterpResult<'
266266
CArg::USize(v.to_scalar().to_target_usize(cx)?.try_into().unwrap()),
267267
ty::RawPtr(..) => {
268268
let s = v.to_scalar().to_pointer(cx)?.addr();
269-
// This relies on the `expose_provenance` in `addr_from_alloc_id`.
269+
// This relies on the `expose_provenance` in `prepare_for_native_call`.
270270
CArg::RawPtr(std::ptr::with_exposed_provenance_mut(s.bytes_usize()))
271271
}
272272
_ => throw_unsup_format!("unsupported argument type for native call: {}", v.layout.ty),

tests/fail/intrinsics/copy_overlapping.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
// Directly call intrinsic to avoid debug assertions in libstd
44
#[rustc_intrinsic]
5-
unsafe fn copy_nonoverlapping<T>(_src: *const T, _dst: *mut T, _count: usize);
5+
unsafe fn copy_nonoverlapping<T>(src: *const T, dst: *mut T, count: usize);
66

77
fn main() {
88
let mut data = [0u8; 16];

tests/fail/intrinsics/copy_unaligned.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
// Directly call intrinsic to avoid debug assertions in libstd
44
#[rustc_intrinsic]
5-
unsafe fn copy_nonoverlapping<T>(_src: *const T, _dst: *mut T, _count: usize);
5+
unsafe fn copy_nonoverlapping<T>(src: *const T, dst: *mut T, count: usize);
66

77
fn main() {
88
let mut data = [0u16; 8];

tests/fail/intrinsics/ctlz_nonzero.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
mod rusti {
44
#[rustc_intrinsic]
5-
pub unsafe fn ctlz_nonzero<T>(_x: T) -> u32;
5+
pub unsafe fn ctlz_nonzero<T>(x: T) -> u32;
66
}
77

88
pub fn main() {

tests/fail/intrinsics/cttz_nonzero.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
mod rusti {
44
#[rustc_intrinsic]
5-
pub unsafe fn cttz_nonzero<T>(_x: T) -> u32;
5+
pub unsafe fn cttz_nonzero<T>(x: T) -> u32;
66
}
77

88
pub fn main() {

tests/fail/intrinsics/float_to_int_32_inf1.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
// Directly call intrinsic to avoid debug assertions in libstd
44
#[rustc_intrinsic]
5-
unsafe fn float_to_int_unchecked<Float: Copy, Int: Copy>(_value: Float) -> Int;
5+
unsafe fn float_to_int_unchecked<Float: Copy, Int: Copy>(value: Float) -> Int;
66

77
fn main() {
88
unsafe {

tests/fail/intrinsics/float_to_int_32_infneg1.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
// Directly call intrinsic to avoid debug assertions in libstd
44
#[rustc_intrinsic]
5-
unsafe fn float_to_int_unchecked<Float: Copy, Int: Copy>(_value: Float) -> Int;
5+
unsafe fn float_to_int_unchecked<Float: Copy, Int: Copy>(value: Float) -> Int;
66

77
fn main() {
88
unsafe {

0 commit comments

Comments
 (0)