about summary refs log tree commit diff
path: root/compiler/rustc_codegen_llvm/src
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2022-02-18 23:18:12 +0000
committerbors <bors@rust-lang.org>2022-02-18 23:18:12 +0000
commit5a1a3707ff3e048c947d8b85d9e1f563775860c8 (patch)
treef01e21e7bd04a478b1e1d9297ba5a417b9387a06 /compiler/rustc_codegen_llvm/src
parentb17226fcc11587fed612631be372a5b4cb89988a (diff)
parent28ca6b0f79ebe238d1deb0c06b0b17396716b958 (diff)
downloadrust-5a1a3707ff3e048c947d8b85d9e1f563775860c8.tar.gz
rust-5a1a3707ff3e048c947d8b85d9e1f563775860c8.zip
Auto merge of #94050 - michaelwoerister:fix-unsized-tuple-debuginfo, r=pnkfelix
debuginfo: Support fat pointers to unsized tuples.

This PR makes fat pointer debuginfo generation handle the case of unsized tuples.

Fixes #93871
Diffstat (limited to 'compiler/rustc_codegen_llvm/src')
-rw-r--r--compiler/rustc_codegen_llvm/src/debuginfo/utils.rs13
1 files changed, 4 insertions, 9 deletions
diff --git a/compiler/rustc_codegen_llvm/src/debuginfo/utils.rs b/compiler/rustc_codegen_llvm/src/debuginfo/utils.rs
index 6dd0d58efe3..acd032a7dc6 100644
--- a/compiler/rustc_codegen_llvm/src/debuginfo/utils.rs
+++ b/compiler/rustc_codegen_llvm/src/debuginfo/utils.rs
@@ -6,7 +6,7 @@ use super::CrateDebugContext;
 use rustc_hir::def_id::DefId;
 use rustc_middle::ty::layout::LayoutOf;
 use rustc_middle::ty::{self, DefIdTree, Ty};
-use rustc_target::abi::VariantIdx;
+use rustc_target::abi::Variants;
 
 use crate::common::CodegenCx;
 use crate::llvm;
@@ -72,20 +72,15 @@ pub(crate) fn fat_pointer_kind<'ll, 'tcx>(
     match *pointee_ty.kind() {
         ty::Str | ty::Slice(_) => Some(FatPtrKind::Slice),
         ty::Dynamic(..) => Some(FatPtrKind::Dyn),
-        ty::Adt(adt_def, _) => {
-            assert!(adt_def.is_struct());
-            assert!(adt_def.variants.len() == 1);
-            let variant = &adt_def.variants[VariantIdx::from_usize(0)];
-            assert!(!variant.fields.is_empty());
-            let last_field_index = variant.fields.len() - 1;
-
+        ty::Adt(..) | ty::Tuple(..) if matches!(layout.variants, Variants::Single { .. }) => {
+            let last_field_index = layout.fields.count() - 1;
             debug_assert!(
                 (0..last_field_index)
                     .all(|field_index| { !layout.field(cx, field_index).is_unsized() })
             );
 
             let unsized_field = layout.field(cx, last_field_index);
-            assert!(unsized_field.is_unsized());
+            debug_assert!(unsized_field.is_unsized());
             fat_pointer_kind(cx, unsized_field.ty)
         }
         ty::Foreign(_) => {