Skip to content

Commit a644f37

Browse files
authored
Rollup merge of #115340 - RalfJung:more_is_1zst, r=oli-obk
some more is_zst that should be is_1zst Follow-up to #115277
2 parents a51e830 + d1c4fe9 commit a644f37

File tree

4 files changed

+8
-8
lines changed

4 files changed

+8
-8
lines changed

compiler/rustc_hir_analysis/src/coherence/builtin.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -195,8 +195,8 @@ fn visit_implementation_of_dispatch_from_dyn(tcx: TyCtxt<'_>, impl_did: LocalDef
195195
let ty_b = field.ty(tcx, args_b);
196196

197197
if let Ok(layout) = tcx.layout_of(param_env.and(ty_a)) {
198-
if layout.is_zst() && layout.align.abi.bytes() == 1 {
199-
// ignore ZST fields with alignment of 1 byte
198+
if layout.is_1zst() {
199+
// ignore 1-ZST fields
200200
return false;
201201
}
202202
}

compiler/rustc_lint/src/types.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -804,7 +804,7 @@ pub(crate) fn nonnull_optimization_guaranteed<'tcx>(
804804
tcx.has_attr(def.did(), sym::rustc_nonnull_optimization_guaranteed)
805805
}
806806

807-
/// `repr(transparent)` structs can have a single non-ZST field, this function returns that
807+
/// `repr(transparent)` structs can have a single non-1-ZST field, this function returns that
808808
/// field.
809809
pub fn transparent_newtype_field<'a, 'tcx>(
810810
tcx: TyCtxt<'tcx>,
@@ -813,8 +813,8 @@ pub fn transparent_newtype_field<'a, 'tcx>(
813813
let param_env = tcx.param_env(variant.def_id);
814814
variant.fields.iter().find(|field| {
815815
let field_ty = tcx.type_of(field.did).instantiate_identity();
816-
let is_zst = tcx.layout_of(param_env.and(field_ty)).is_ok_and(|layout| layout.is_zst());
817-
!is_zst
816+
let is_1zst = tcx.layout_of(param_env.and(field_ty)).is_ok_and(|layout| layout.is_1zst());
817+
!is_1zst
818818
})
819819
}
820820

compiler/rustc_ty_utils/src/abi.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -592,13 +592,13 @@ fn make_thin_self_ptr<'tcx>(
592592
for i in 0..fat_pointer_layout.fields.count() {
593593
let field_layout = fat_pointer_layout.field(cx, i);
594594

595-
if !field_layout.is_zst() {
595+
if !field_layout.is_1zst() {
596596
fat_pointer_layout = field_layout;
597597
continue 'descend_newtypes;
598598
}
599599
}
600600

601-
bug!("receiver has no non-zero-sized fields {:?}", fat_pointer_layout);
601+
bug!("receiver has no non-1-ZST fields {:?}", fat_pointer_layout);
602602
}
603603

604604
fat_pointer_layout.ty

compiler/rustc_ty_utils/src/layout.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ fn layout_of_uncached<'tcx>(
192192

193193
let metadata_layout = cx.layout_of(metadata_ty)?;
194194
// If the metadata is a 1-zst, then the pointer is thin.
195-
if metadata_layout.is_zst() && metadata_layout.align.abi.bytes() == 1 {
195+
if metadata_layout.is_1zst() {
196196
return Ok(tcx.mk_layout(LayoutS::scalar(cx, data_ptr)));
197197
}
198198

0 commit comments

Comments
 (0)