Skip to content

Commit 2c15b3c

Browse files
committed
less unsupported errors in Miri, and clarifying comments
1 parent ccc6ffb commit 2c15b3c

File tree

3 files changed

+12
-12
lines changed

3 files changed

+12
-12
lines changed

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

+3-2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ pub struct ProvenanceMap<Prov = AllocId> {
1616
/// bytes. Two entires in this map are always at least a pointer size apart.
1717
ptrs: SortedMap<Size, Prov>,
1818
/// Provenance in this map only applies to the given single byte.
19-
/// This map is disjoint from the previous.
19+
/// This map is disjoint from the previous. It will always be empty when
20+
/// `Prov::OFFSET_IS_ADDR` is false.
2021
bytes: SortedMap<Size, Prov>,
2122
}
2223

@@ -39,7 +40,7 @@ impl ProvenanceMap {
3940
/// Only exposed with `AllocId` provenance, since it panics if there is bytewise provenance.
4041
#[inline]
4142
pub fn ptrs(&self) -> &SortedMap<Size, AllocId> {
42-
debug_assert!(self.bytes.is_empty());
43+
debug_assert!(self.bytes.is_empty()); // `AllocId::OFFSET_IS_ADDR` is false so this cannot fail
4344
&self.ptrs
4445
}
4546
}

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

+6-7
Original file line numberDiff line numberDiff line change
@@ -401,16 +401,15 @@ impl fmt::Display for UndefinedBehaviorInfo {
401401
pub enum UnsupportedOpInfo {
402402
/// Free-form case. Only for errors that are never caught!
403403
Unsupported(String),
404-
/// Overwriting parts of a pointer; the resulting state cannot be represented in our
405-
/// `Allocation` data structure. See <https://github.com/rust-lang/miri/issues/2181>.
406-
PartialPointerOverwrite(Pointer<AllocId>),
407-
/// Attempting to `copy` parts of a pointer to somewhere else; the resulting state cannot be
408-
/// represented in our `Allocation` data structure. See
409-
/// <https://github.com/rust-lang/miri/issues/2181>.
410-
PartialPointerCopy(Pointer<AllocId>),
411404
//
412405
// The variants below are only reachable from CTFE/const prop, miri will never emit them.
413406
//
407+
/// Overwriting parts of a pointer; without knowing absolute addresses, the resulting state
408+
/// cannot be represented by the CTFE interpreter.
409+
PartialPointerOverwrite(Pointer<AllocId>),
410+
/// Attempting to `copy` parts of a pointer to somewhere else; without knowing absolute
411+
/// addresses, the resulting state cannot be represented by the CTFE interpreter.
412+
PartialPointerCopy(Pointer<AllocId>),
414413
/// Encountered a pointer where we needed raw bytes.
415414
ReadPointerAsBytes,
416415
/// Accessing thread local statics

src/tools/miri/src/diagnostics.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -229,13 +229,13 @@ pub fn report_error<'tcx, 'mir>(
229229
Unsupported(
230230
UnsupportedOpInfo::ThreadLocalStatic(_) |
231231
UnsupportedOpInfo::ReadExternStatic(_) |
232-
UnsupportedOpInfo::PartialPointerOverwrite(_) | // we make memory uninit instead
232+
UnsupportedOpInfo::PartialPointerOverwrite(_) |
233+
UnsupportedOpInfo::PartialPointerCopy(_) |
233234
UnsupportedOpInfo::ReadPointerAsBytes
234235
) =>
235236
panic!("Error should never be raised by Miri: {kind:?}", kind = e.kind()),
236237
Unsupported(
237-
UnsupportedOpInfo::Unsupported(_) |
238-
UnsupportedOpInfo::PartialPointerCopy(_)
238+
UnsupportedOpInfo::Unsupported(_)
239239
) =>
240240
vec![(None, format!("this is likely not a bug in the program; it indicates that the program performed an operation that the interpreter does not support"))],
241241
UndefinedBehavior(UndefinedBehaviorInfo::AlignmentCheckFailed { .. })

0 commit comments

Comments
 (0)