Skip to content

Commit 9d57adf

Browse files
committed
Explain {read,write}_scalar failure to cope with zsts
1 parent 8b04b09 commit 9d57adf

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/librustc/mir/interpret/allocation.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,11 @@ impl<'tcx, Tag: Copy, Extra: AllocationExtra<Tag>> Allocation<Tag, Extra> {
231231
}
232232

233233
/// Read a *non-ZST* scalar
234+
///
235+
/// zsts can't be read out of two reasons:
236+
/// * byteorder cannot work with zero element buffers
237+
/// * in oder to obtain a `Pointer` we need to check for ZSTness anyway due to integer pointers
238+
/// being valid for ZSTs
234239
pub fn read_scalar(
235240
&self,
236241
cx: &impl HasDataLayout,
@@ -274,6 +279,11 @@ impl<'tcx, Tag: Copy, Extra: AllocationExtra<Tag>> Allocation<Tag, Extra> {
274279
}
275280

276281
/// Write a *non-ZST* scalar
282+
///
283+
/// zsts can't be read out of two reasons:
284+
/// * byteorder cannot work with zero element buffers
285+
/// * in oder to obtain a `Pointer` we need to check for ZSTness anyway due to integer pointers
286+
/// being valid for ZSTs
277287
pub fn write_scalar(
278288
&mut self,
279289
cx: &impl HasDataLayout,

0 commit comments

Comments
 (0)