Skip to content

Commit dc693ff

Browse files
committed
code review commits (use rustc_data_structures::fx::FxHashSet, prepare_for_native_write, document write_wildcards
1 parent 193cca2 commit dc693ff

File tree

4 files changed

+8
-5
lines changed

4 files changed

+8
-5
lines changed

compiler/rustc_const_eval/src/interpret/memory.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -952,7 +952,7 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
952952
// Expose provenance of the root allocation.
953953
M::expose_provenance(self, initial_prov)?;
954954

955-
let mut done = rustc_data_structures::fx::FxHashSet::default();
955+
let mut done = FxHashSet::default();
956956
let mut todo = vec![id];
957957
while let Some(id) = todo.pop() {
958958
if !done.insert(id) {
@@ -979,7 +979,7 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
979979
if info.mutbl.is_mut() {
980980
self.get_alloc_raw_mut(id)?
981981
.0
982-
.prepare_for_native_call()
982+
.prepare_for_native_write()
983983
.map_err(|e| e.to_interp_error(id))?;
984984
}
985985
}

compiler/rustc_middle/src/mir/interpret/allocation.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -646,7 +646,7 @@ impl<Prov: Provenance, Extra, Bytes: AllocBytes> Allocation<Prov, Extra, Bytes>
646646
/// Initialize all previously uninitialized bytes in the entire allocation, and set
647647
/// provenance of everything to `Wildcard`. Before calling this, make sure all
648648
/// provenance in this allocation is exposed!
649-
pub fn prepare_for_native_call(&mut self) -> AllocResult {
649+
pub fn prepare_for_native_write(&mut self) -> AllocResult {
650650
let full_range = AllocRange { start: Size::ZERO, size: Size::from_bytes(self.len()) };
651651
// Overwrite uninitialized bytes with 0, to ensure we don't leak whatever their value happens to be.
652652
for chunk in self.init_mask.range_as_init_chunks(full_range) {

compiler/rustc_middle/src/mir/interpret/allocation/provenance_map.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,8 +195,11 @@ impl<Prov: Provenance> ProvenanceMap<Prov> {
195195

196196
Ok(())
197197
}
198+
199+
/// Overwrites all provenance in the allocation with wildcard provenance.
200+
///
201+
/// Provided for usage in Miri and panics otherwise.
198202
pub fn write_wildcards(&mut self, alloc_size: usize) {
199-
// We can only write wildcards in Miri.
200203
assert!(
201204
Prov::OFFSET_IS_ADDR,
202205
"writing wildcard provenance is not supported when `OFFSET_IS_ADDR` is false"

src/tools/miri/tests/native-lib/ptr_write_access.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,4 +51,4 @@ EXPORT void overwrite_ptr(const int **pptr) {
5151

5252
EXPORT void blackbox(__attribute__((unused)) const int ***_ppptr) {
5353
return;
54-
}
54+
}

0 commit comments

Comments
 (0)