about summary refs log tree commit diff
diff options
context:
space:
mode:
authorRalf Jung <post@ralfj.de>2023-08-27 18:12:34 +0200
committerRalf Jung <post@ralfj.de>2023-08-29 09:03:46 +0200
commit833592766f9e317e7166ffff1444ff70c6fdeda4 (patch)
tree2da11d4941b77d3a28ffa11538f44cc2a352b7ad
parent25a2ba2ee4febf9c22f7add7e14a0a50b3fd984d (diff)
downloadrust-833592766f9e317e7166ffff1444ff70c6fdeda4.tar.gz
rust-833592766f9e317e7166ffff1444ff70c6fdeda4.zip
const_eval and codegen: audit uses of is_zst
-rw-r--r--src/unsize.rs4
-rw-r--r--src/vtable.rs4
2 files changed, 5 insertions, 3 deletions
diff --git a/src/unsize.rs b/src/unsize.rs
index 6aeba13f639..c6133f2b35c 100644
--- a/src/unsize.rs
+++ b/src/unsize.rs
@@ -88,7 +88,8 @@ fn unsize_ptr<'tcx>(
                 let src_f = src_layout.field(fx, i);
                 assert_eq!(src_layout.fields.offset(i).bytes(), 0);
                 assert_eq!(dst_layout.fields.offset(i).bytes(), 0);
-                if src_f.is_zst() {
+                if src_f.is_1zst() {
+                    // We are looking for the one non-1-ZST field; this is not it.
                     continue;
                 }
                 assert_eq!(src_layout.size, src_f.size);
@@ -151,6 +152,7 @@ pub(crate) fn coerce_unsized_into<'tcx>(
                 let dst_f = dst.place_field(fx, FieldIdx::new(i));
 
                 if dst_f.layout().is_zst() {
+                    // No data here, nothing to copy/coerce.
                     continue;
                 }
 
diff --git a/src/vtable.rs b/src/vtable.rs
index b309695c190..7598c6eee03 100644
--- a/src/vtable.rs
+++ b/src/vtable.rs
@@ -51,8 +51,8 @@ pub(crate) fn get_ptr_and_method_ref<'tcx>(
             'descend_newtypes: while !arg.layout().ty.is_unsafe_ptr() && !arg.layout().ty.is_ref() {
                 for i in 0..arg.layout().fields.count() {
                     let field = arg.value_field(fx, FieldIdx::new(i));
-                    if !field.layout().is_zst() {
-                        // we found the one non-zero-sized field that is allowed
+                    if !field.layout().is_1zst() {
+                        // we found the one non-1-ZST field that is allowed
                         // now find *its* non-zero-sized field, or stop if it's a
                         // pointer
                         arg = field;