about summary refs log tree commit diff
path: root/src/librustc/mir
diff options
context:
space:
mode:
authorOliver Scherer <github35764891676564198441@oli-obk.de>2018-11-15 14:48:34 +0100
committerOliver Scherer <github35764891676564198441@oli-obk.de>2018-11-24 11:36:32 +0100
commit9d57adf2ba57420903b4c9b4dbb492c3fcf691b8 (patch)
treeb12b37c7ee83d0b8712c575e1191b4f0cc9d584d /src/librustc/mir
parent8b04b098695951f561ef4eedf33c6fbc63728caa (diff)
downloadrust-9d57adf2ba57420903b4c9b4dbb492c3fcf691b8.tar.gz
rust-9d57adf2ba57420903b4c9b4dbb492c3fcf691b8.zip
Explain {read,write}_scalar failure to cope with zsts
Diffstat (limited to 'src/librustc/mir')
-rw-r--r--src/librustc/mir/interpret/allocation.rs10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/librustc/mir/interpret/allocation.rs b/src/librustc/mir/interpret/allocation.rs
index b2c44548805..2ecd5eb5a62 100644
--- a/src/librustc/mir/interpret/allocation.rs
+++ b/src/librustc/mir/interpret/allocation.rs
@@ -231,6 +231,11 @@ impl<'tcx, Tag: Copy, Extra: AllocationExtra<Tag>> Allocation<Tag, Extra> {
     }
 
     /// Read a *non-ZST* scalar
+    ///
+    /// zsts can't be read out of two reasons:
+    /// * byteorder cannot work with zero element buffers
+    /// * in oder to obtain a `Pointer` we need to check for ZSTness anyway due to integer pointers
+    ///   being valid for ZSTs
     pub fn read_scalar(
         &self,
         cx: &impl HasDataLayout,
@@ -274,6 +279,11 @@ impl<'tcx, Tag: Copy, Extra: AllocationExtra<Tag>> Allocation<Tag, Extra> {
     }
 
     /// Write a *non-ZST* scalar
+    ///
+    /// zsts can't be read out of two reasons:
+    /// * byteorder cannot work with zero element buffers
+    /// * in oder to obtain a `Pointer` we need to check for ZSTness anyway due to integer pointers
+    ///   being valid for ZSTs
     pub fn write_scalar(
         &mut self,
         cx: &impl HasDataLayout,