Skip to content

Commit a835555

Browse files
committed
Make zst accesses in allocations take the regular path.
Speeding up zst accesses should be done on a higher level.
1 parent 3a0e825 commit a835555

File tree

1 file changed

+0
-21
lines changed

1 file changed

+0
-21
lines changed

src/librustc/mir/interpret/allocation.rs

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -116,12 +116,7 @@ impl<'tcx, Tag: Copy, Extra: AllocationExtra<Tag>> Allocation<Tag, Extra> {
116116
size: Size,
117117
allow_ptr_and_undef: bool,
118118
) -> EvalResult<'tcx> {
119-
// Empty accesses don't need to be valid pointers, but they should still be non-NULL
120119
let align = Align::from_bytes(1).unwrap();
121-
if size.bytes() == 0 {
122-
self.check_align(ptr, align)?;
123-
return Ok(());
124-
}
125120
// Check bounds, align and relocations on the edges
126121
self.get_bytes_with_undef_and_ptr(cx, ptr, size, align)?;
127122
// Check undef and ptr
@@ -138,12 +133,7 @@ impl<'tcx, Tag: Copy, Extra: AllocationExtra<Tag>> Allocation<Tag, Extra> {
138133
ptr: Pointer<Tag>,
139134
size: Size,
140135
) -> EvalResult<'tcx, &[u8]> {
141-
// Empty accesses don't need to be valid pointers, but they should still be non-NULL
142136
let align = Align::from_bytes(1).unwrap();
143-
if size.bytes() == 0 {
144-
self.check_align(ptr, align)?;
145-
return Ok(&[]);
146-
}
147137
self.get_bytes(cx, ptr, size, align)
148138
}
149139

@@ -153,12 +143,7 @@ impl<'tcx, Tag: Copy, Extra: AllocationExtra<Tag>> Allocation<Tag, Extra> {
153143
ptr: Pointer<Tag>,
154144
src: &[u8],
155145
) -> EvalResult<'tcx> {
156-
// Empty accesses don't need to be valid pointers, but they should still be non-NULL
157146
let align = Align::from_bytes(1).unwrap();
158-
if src.is_empty() {
159-
self.check_align(ptr, align)?;
160-
return Ok(());
161-
}
162147
let bytes = self.get_bytes_mut(
163148
cx, ptr, Size::from_bytes(src.len() as u64), align,
164149
)?;
@@ -173,12 +158,7 @@ impl<'tcx, Tag: Copy, Extra: AllocationExtra<Tag>> Allocation<Tag, Extra> {
173158
val: u8,
174159
count: Size
175160
) -> EvalResult<'tcx> {
176-
// Empty accesses don't need to be valid pointers, but they should still be non-NULL
177161
let align = Align::from_bytes(1).unwrap();
178-
if count.bytes() == 0 {
179-
self.check_align(ptr, align)?;
180-
return Ok(());
181-
}
182162
let bytes = self.get_bytes_mut(cx, ptr, count, align)?;
183163
for b in bytes {
184164
*b = val;
@@ -329,7 +309,6 @@ impl<'tcx, Tag: Copy, Extra: AllocationExtra<Tag>> Allocation<Tag, Extra> {
329309
align: Align,
330310
check_defined_and_ptr: bool,
331311
) -> EvalResult<'tcx, &[u8]> {
332-
assert_ne!(size.bytes(), 0, "0-sized accesses should never even get a `Pointer`");
333312
self.check_align(ptr.into(), align)?;
334313
self.check_bounds(cx, ptr, size)?;
335314

0 commit comments

Comments
 (0)