diff options
| author | bors <bors@rust-lang.org> | 2023-08-29 10:22:35 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2023-08-29 10:22:35 +0000 |
| commit | 0b84f18b24c8cb9a2f83b21c0d93c54ea4bb76e8 (patch) | |
| tree | e5f7c93b0f589b0aaee74b7ddbfd40a5d662d76c /compiler/rustc_codegen_llvm/src | |
| parent | f6faef447536204549eb47f12884d3e229fe87d3 (diff) | |
| parent | b2ebf1c23f93886ba7d3738878f04e275add4ead (diff) | |
| download | rust-0b84f18b24c8cb9a2f83b21c0d93c54ea4bb76e8.tar.gz rust-0b84f18b24c8cb9a2f83b21c0d93c54ea4bb76e8.zip | |
Auto merge of #115277 - RalfJung:is_1zst, r=davidtwco
fix some issues around ZST handling This fixes two bugs: - We used to entirely skip enum variants like `B([u16; 0], !)`, even failing to properly align the enum! Honoring the alignment of uninhabited variants is important for the same reason that we must reserve space for their fields -- see [here](https://github.com/rust-lang/rust/issues/49298#issuecomment-380615281) for why. - ~~We uses to reject `repr(transparent)` on `struct MyType([u16; 0])`, which is weird because a one-field struct should always be allowed to be transparent around that field.~~ (moved to separate PR) I also found two places in the layout code that did something special for ZST without explaining why, and removing those special cases doesn't seem to have any effect except for reordering some zero-sized fields which shouldn't be an issue... maybe PR CI will explain why those cases were needed, or maybe they became obsolete at some point.
Diffstat (limited to 'compiler/rustc_codegen_llvm/src')
| -rw-r--r-- | compiler/rustc_codegen_llvm/src/debuginfo/metadata.rs | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/compiler/rustc_codegen_llvm/src/debuginfo/metadata.rs b/compiler/rustc_codegen_llvm/src/debuginfo/metadata.rs index f8cbcbd5ec8..ed938761694 100644 --- a/compiler/rustc_codegen_llvm/src/debuginfo/metadata.rs +++ b/compiler/rustc_codegen_llvm/src/debuginfo/metadata.rs @@ -445,9 +445,9 @@ pub fn type_di_node<'ll, 'tcx>(cx: &CodegenCx<'ll, 'tcx>, t: Ty<'tcx>) -> &'ll D ty::RawPtr(ty::TypeAndMut { ty: pointee_type, .. }) | ty::Ref(_, pointee_type, _) => { build_pointer_or_reference_di_node(cx, t, pointee_type, unique_type_id) } - // Box<T, A> may have a non-ZST allocator A. In that case, we + // Box<T, A> may have a non-1-ZST allocator A. In that case, we // cannot treat Box<T, A> as just an owned alias of `*mut T`. - ty::Adt(def, args) if def.is_box() && cx.layout_of(args.type_at(1)).is_zst() => { + ty::Adt(def, args) if def.is_box() && cx.layout_of(args.type_at(1)).is_1zst() => { build_pointer_or_reference_di_node(cx, t, t.boxed_ty(), unique_type_id) } ty::FnDef(..) | ty::FnPtr(_) => build_subroutine_type_di_node(cx, unique_type_id), |
