Skip to content

Commit 9b2c4a4

Browse files
committed
review
1 parent f03b6fb commit 9b2c4a4

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

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

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,17 @@ impl<Prov: Provenance> ProvenanceMap<Prov> {
120120
}
121121
}
122122

123+
/// Gets the provenances of all bytes (including from pointers) in a range.
124+
pub fn get_range(
125+
&self,
126+
cx: &impl HasDataLayout,
127+
range: AllocRange,
128+
) -> impl Iterator<Item = Prov> {
129+
let ptr_provs = self.range_ptrs_get(range, cx).iter().map(|(_, p)| *p);
130+
let byte_provs = self.range_bytes_get(range).iter().map(|(_, (p, _))| *p);
131+
ptr_provs.chain(byte_provs)
132+
}
133+
123134
/// Attempt to merge per-byte provenance back into ptr chunks, if the right fragments
124135
/// sit next to each other. Return `false` is that is not possible due to partial pointers.
125136
pub fn merge_bytes(&mut self, cx: &impl HasDataLayout) -> bool {
@@ -148,17 +159,6 @@ impl<Prov: Provenance> ProvenanceMap<Prov> {
148159
true
149160
}
150161

151-
/// Gets the provenances of all bytes (including from pointers) in a range.
152-
pub fn get_range(
153-
&self,
154-
cx: &impl HasDataLayout,
155-
range: AllocRange,
156-
) -> impl Iterator<Item = (Size, Prov)> {
157-
let ptr_provs = self.range_ptrs_get(range, cx).to_owned();
158-
let byte_provs = self.range_bytes_get(range).into_iter().map(|&(s, (p, _))| (s, p));
159-
ptr_provs.into_iter().chain(byte_provs)
160-
}
161-
162162
/// Check if there is ptr-sized provenance at the given index.
163163
/// Does not mean anything for bytewise provenance! But can be useful as an optimization.
164164
pub fn get_ptr(&self, offset: Size) -> Option<Prov> {

src/tools/miri/src/shims/native_lib/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ trait EvalContextExtPriv<'tcx>: crate::MiriInterpCxExt<'tcx> {
243243
match evt {
244244
AccessEvent::Read(_) => {
245245
// If a provenance was read by the foreign code, expose it.
246-
for (_, prov) in alloc.provenance().get_range(this, overlap.into()) {
246+
for prov in alloc.provenance().get_range(this, overlap.into()) {
247247
this.expose_provenance(prov)?;
248248
}
249249
}

0 commit comments

Comments
 (0)