Skip to content

Commit 0273f29

Browse files
committed
Improve zero sized panic message
1 parent d61e158 commit 0273f29

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

src/distributed_slice.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,9 @@ impl<T> DistributedSlice<[T]> {
163163
dupcheck_start: *const (),
164164
dupcheck_stop: *const (),
165165
) -> Self {
166-
assert!(mem::size_of::<T>() > 0);
166+
if mem::size_of::<T>() == 0 {
167+
panic!("#[distributed_slice] requires that the slice element type has nonzero size");
168+
}
167169

168170
DistributedSlice {
169171
name,

tests/ui/zerosized.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
error[E0080]: evaluation panicked: assertion failed: mem::size_of::<T>() > 0
1+
error[E0080]: evaluation panicked: #[distributed_slice] requires that the slice element type has nonzero size
22
--> tests/ui/zerosized.rs:7:1
33
|
44
7 | #[distributed_slice]

0 commit comments

Comments
 (0)