]> git.lizzy.rs Git - rust.git/commitdiff
Explain {read,write}_scalar failure to cope with zsts
authorOliver Scherer <github35764891676564198441@oli-obk.de>
Thu, 15 Nov 2018 13:48:34 +0000 (14:48 +0100)
committerOliver Scherer <github35764891676564198441@oli-obk.de>
Sat, 24 Nov 2018 10:36:32 +0000 (11:36 +0100)
src/librustc/mir/interpret/allocation.rs

index b2c4454880575264efcf8a924090c1dc885bf334..2ecd5eb5a626922001a6a025e7dc9f5f4d72ca74 100644 (file)
@@ -231,6 +231,11 @@ pub fn write_repeat(
     }
 
     /// 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 @@ pub fn read_ptr_sized(
     }
 
     /// 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,