diff options
| author | Ralf Jung <post@ralfj.de> | 2022-11-07 19:12:24 +0100 |
|---|---|---|
| committer | Ralf Jung <post@ralfj.de> | 2022-11-07 23:54:49 +0100 |
| commit | 2c15b3c08cbd5d0932b47b1a2361470562113384 (patch) | |
| tree | 89aec67e5e86883d13e16f5d7813482c14973d32 | |
| parent | ccc6ffb03dcfeba1d3a91aa24a2cb094350605ec (diff) | |
| download | rust-2c15b3c08cbd5d0932b47b1a2361470562113384.tar.gz rust-2c15b3c08cbd5d0932b47b1a2361470562113384.zip | |
less unsupported errors in Miri, and clarifying comments
| -rw-r--r-- | compiler/rustc_middle/src/mir/interpret/allocation/provenance_map.rs | 5 | ||||
| -rw-r--r-- | compiler/rustc_middle/src/mir/interpret/error.rs | 13 | ||||
| -rw-r--r-- | src/tools/miri/src/diagnostics.rs | 6 |
3 files changed, 12 insertions, 12 deletions
diff --git a/compiler/rustc_middle/src/mir/interpret/allocation/provenance_map.rs b/compiler/rustc_middle/src/mir/interpret/allocation/provenance_map.rs index 2e2829dd835..5a1498e9031 100644 --- a/compiler/rustc_middle/src/mir/interpret/allocation/provenance_map.rs +++ b/compiler/rustc_middle/src/mir/interpret/allocation/provenance_map.rs @@ -16,7 +16,8 @@ pub struct ProvenanceMap<Prov = AllocId> { /// bytes. Two entires in this map are always at least a pointer size apart. ptrs: SortedMap<Size, Prov>, /// Provenance in this map only applies to the given single byte. - /// This map is disjoint from the previous. + /// This map is disjoint from the previous. It will always be empty when + /// `Prov::OFFSET_IS_ADDR` is false. bytes: SortedMap<Size, Prov>, } @@ -39,7 +40,7 @@ impl ProvenanceMap { /// Only exposed with `AllocId` provenance, since it panics if there is bytewise provenance. #[inline] pub fn ptrs(&self) -> &SortedMap<Size, AllocId> { - debug_assert!(self.bytes.is_empty()); + debug_assert!(self.bytes.is_empty()); // `AllocId::OFFSET_IS_ADDR` is false so this cannot fail &self.ptrs } } diff --git a/compiler/rustc_middle/src/mir/interpret/error.rs b/compiler/rustc_middle/src/mir/interpret/error.rs index b5a50cc1527..1ea8baa3cae 100644 --- a/compiler/rustc_middle/src/mir/interpret/error.rs +++ b/compiler/rustc_middle/src/mir/interpret/error.rs @@ -401,16 +401,15 @@ impl fmt::Display for UndefinedBehaviorInfo { pub enum UnsupportedOpInfo { /// Free-form case. Only for errors that are never caught! Unsupported(String), - /// Overwriting parts of a pointer; the resulting state cannot be represented in our - /// `Allocation` data structure. See <https://github.com/rust-lang/miri/issues/2181>. - PartialPointerOverwrite(Pointer<AllocId>), - /// Attempting to `copy` parts of a pointer to somewhere else; the resulting state cannot be - /// represented in our `Allocation` data structure. See - /// <https://github.com/rust-lang/miri/issues/2181>. - PartialPointerCopy(Pointer<AllocId>), // // The variants below are only reachable from CTFE/const prop, miri will never emit them. // + /// Overwriting parts of a pointer; without knowing absolute addresses, the resulting state + /// cannot be represented by the CTFE interpreter. + PartialPointerOverwrite(Pointer<AllocId>), + /// Attempting to `copy` parts of a pointer to somewhere else; without knowing absolute + /// addresses, the resulting state cannot be represented by the CTFE interpreter. + PartialPointerCopy(Pointer<AllocId>), /// Encountered a pointer where we needed raw bytes. ReadPointerAsBytes, /// Accessing thread local statics diff --git a/src/tools/miri/src/diagnostics.rs b/src/tools/miri/src/diagnostics.rs index ec81ffd3cd5..0cfa3812e40 100644 --- a/src/tools/miri/src/diagnostics.rs +++ b/src/tools/miri/src/diagnostics.rs @@ -229,13 +229,13 @@ pub fn report_error<'tcx, 'mir>( Unsupported( UnsupportedOpInfo::ThreadLocalStatic(_) | UnsupportedOpInfo::ReadExternStatic(_) | - UnsupportedOpInfo::PartialPointerOverwrite(_) | // we make memory uninit instead + UnsupportedOpInfo::PartialPointerOverwrite(_) | + UnsupportedOpInfo::PartialPointerCopy(_) | UnsupportedOpInfo::ReadPointerAsBytes ) => panic!("Error should never be raised by Miri: {kind:?}", kind = e.kind()), Unsupported( - UnsupportedOpInfo::Unsupported(_) | - UnsupportedOpInfo::PartialPointerCopy(_) + UnsupportedOpInfo::Unsupported(_) ) => 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"))], UndefinedBehavior(UndefinedBehaviorInfo::AlignmentCheckFailed { .. }) |
