Skip to content

Commit 8335927

Browse files
committed
const_eval and codegen: audit uses of is_zst
1 parent 25a2ba2 commit 8335927

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

src/unsize.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,8 @@ fn unsize_ptr<'tcx>(
8888
let src_f = src_layout.field(fx, i);
8989
assert_eq!(src_layout.fields.offset(i).bytes(), 0);
9090
assert_eq!(dst_layout.fields.offset(i).bytes(), 0);
91-
if src_f.is_zst() {
91+
if src_f.is_1zst() {
92+
// We are looking for the one non-1-ZST field; this is not it.
9293
continue;
9394
}
9495
assert_eq!(src_layout.size, src_f.size);
@@ -151,6 +152,7 @@ pub(crate) fn coerce_unsized_into<'tcx>(
151152
let dst_f = dst.place_field(fx, FieldIdx::new(i));
152153

153154
if dst_f.layout().is_zst() {
155+
// No data here, nothing to copy/coerce.
154156
continue;
155157
}
156158

src/vtable.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ pub(crate) fn get_ptr_and_method_ref<'tcx>(
5151
'descend_newtypes: while !arg.layout().ty.is_unsafe_ptr() && !arg.layout().ty.is_ref() {
5252
for i in 0..arg.layout().fields.count() {
5353
let field = arg.value_field(fx, FieldIdx::new(i));
54-
if !field.layout().is_zst() {
55-
// we found the one non-zero-sized field that is allowed
54+
if !field.layout().is_1zst() {
55+
// we found the one non-1-ZST field that is allowed
5656
// now find *its* non-zero-sized field, or stop if it's a
5757
// pointer
5858
arg = field;

0 commit comments

Comments
 (0)