diff options
| author | bors <bors@rust-lang.org> | 2022-03-25 01:20:01 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2022-03-25 01:20:01 +0000 |
| commit | 661e8beec1fa5f3c58bf6e4362ae3c3fe0b4b1bd (patch) | |
| tree | 87cb397401b3b8a18e4d4b2356a05d1094d54ecf /compiler/rustc_codegen_llvm/src | |
| parent | 7941b3f1473331d2abb2b8796046adc0105c8f94 (diff) | |
| parent | 3716c4275f0c6aa29bd2c87954b483e9c7a97475 (diff) | |
| download | rust-661e8beec1fa5f3c58bf6e4362ae3c3fe0b4b1bd.tar.gz rust-661e8beec1fa5f3c58bf6e4362ae3c3fe0b4b1bd.zip | |
Auto merge of #95291 - Dylan-DPC:rollup-vrb4wlw, r=Dylan-DPC
Rollup of 5 pull requests Successful merges: - #94391 (Fix ice when error reporting recursion errors) - #94655 (Clarify which kinds of MIR are allowed during which phases.) - #95179 (Try to evaluate in try unify and postpone resolution of constants that contain inference variables) - #95270 (debuginfo: Fix debuginfo for Box<T> where T is unsized.) - #95276 (add diagnostic items for clippy's `trim_split_whitespace`) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
Diffstat (limited to 'compiler/rustc_codegen_llvm/src')
| -rw-r--r-- | compiler/rustc_codegen_llvm/src/debuginfo/metadata.rs | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/compiler/rustc_codegen_llvm/src/debuginfo/metadata.rs b/compiler/rustc_codegen_llvm/src/debuginfo/metadata.rs index f02c7b2d2e1..74e194750fa 100644 --- a/compiler/rustc_codegen_llvm/src/debuginfo/metadata.rs +++ b/compiler/rustc_codegen_llvm/src/debuginfo/metadata.rs @@ -166,6 +166,13 @@ fn build_pointer_or_reference_di_node<'ll, 'tcx>( pointee_type: Ty<'tcx>, unique_type_id: UniqueTypeId<'tcx>, ) -> DINodeCreationResult<'ll> { + // The debuginfo generated by this function is only valid if `ptr_type` is really just + // a (fat) pointer. Make sure it is not called for e.g. `Box<T, NonZSTAllocator>`. + debug_assert_eq!( + cx.size_and_align_of(ptr_type), + cx.size_and_align_of(cx.tcx.mk_mut_ptr(pointee_type)) + ); + let pointee_type_di_node = type_di_node(cx, pointee_type); return_if_di_node_created_in_meantime!(cx, unique_type_id); @@ -212,7 +219,17 @@ fn build_pointer_or_reference_di_node<'ll, 'tcx>( DIFlags::FlagZero, ), |cx, owner| { - let layout = cx.layout_of(ptr_type); + // FIXME: If this fat pointer is a `Box` then we don't want to use its + // type layout and instead use the layout of the raw pointer inside + // of it. + // The proper way to handle this is to not treat Box as a pointer + // at all and instead emit regular struct debuginfo for it. We just + // need to make sure that we don't break existing debuginfo consumers + // by doing that (at least not without a warning period). + let layout_type = + if ptr_type.is_box() { cx.tcx.mk_mut_ptr(pointee_type) } else { ptr_type }; + + let layout = cx.layout_of(layout_type); let addr_field = layout.field(cx, abi::FAT_PTR_ADDR); let extra_field = layout.field(cx, abi::FAT_PTR_EXTRA); |
