diff options
| author | bors <bors@rust-lang.org> | 2022-02-24 22:29:14 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2022-02-24 22:29:14 +0000 |
| commit | 4e82f35492ea5c78e19609bf4468f0a686d9a756 (patch) | |
| tree | 23fbd4cd23c587684432375a288e303b80be8051 /compiler/rustc_codegen_llvm/src/debuginfo/utils.rs | |
| parent | 4b043faba34ccc053a4d0110634c323f6c03765e (diff) | |
| parent | 3bd163f4e8422db4c0de384b2b21bfaaecd2e5c1 (diff) | |
| download | rust-4e82f35492ea5c78e19609bf4468f0a686d9a756.tar.gz rust-4e82f35492ea5c78e19609bf4468f0a686d9a756.zip | |
Auto merge of #94333 - Dylan-DPC:rollup-7yxtywp, r=Dylan-DPC
Rollup of 9 pull requests Successful merges: - #91795 (resolve/metadata: Stop encoding macros as reexports) - #93714 (better ObligationCause for normalization errors in `can_type_implement_copy`) - #94175 (Improve `--check-cfg` implementation) - #94212 (Stop manually SIMDing in `swap_nonoverlapping`) - #94242 (properly handle fat pointers to uninhabitable types) - #94308 (Normalize main return type during mono item collection & codegen) - #94315 (update auto trait lint for `PhantomData`) - #94316 (Improve string literal unescaping) - #94327 (Avoid emitting full macro body into JSON errors) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
Diffstat (limited to 'compiler/rustc_codegen_llvm/src/debuginfo/utils.rs')
| -rw-r--r-- | compiler/rustc_codegen_llvm/src/debuginfo/utils.rs | 33 |
1 files changed, 16 insertions, 17 deletions
diff --git a/compiler/rustc_codegen_llvm/src/debuginfo/utils.rs b/compiler/rustc_codegen_llvm/src/debuginfo/utils.rs index acd032a7dc6..fa75463067f 100644 --- a/compiler/rustc_codegen_llvm/src/debuginfo/utils.rs +++ b/compiler/rustc_codegen_llvm/src/debuginfo/utils.rs @@ -4,9 +4,9 @@ use super::namespace::item_namespace; use super::CrateDebugContext; use rustc_hir::def_id::DefId; -use rustc_middle::ty::layout::LayoutOf; +use rustc_middle::ty::layout::{HasParamEnv, LayoutOf}; use rustc_middle::ty::{self, DefIdTree, Ty}; -use rustc_target::abi::Variants; +use tracing::trace; use crate::common::CodegenCx; use crate::llvm; @@ -63,30 +63,26 @@ pub(crate) fn fat_pointer_kind<'ll, 'tcx>( cx: &CodegenCx<'ll, 'tcx>, pointee_ty: Ty<'tcx>, ) -> Option<FatPtrKind> { - let layout = cx.layout_of(pointee_ty); + let pointee_tail_ty = cx.tcx.struct_tail_erasing_lifetimes(pointee_ty, cx.param_env()); + let layout = cx.layout_of(pointee_tail_ty); + trace!( + "fat_pointer_kind: {:?} has layout {:?} (is_unsized? {})", + pointee_tail_ty, + layout, + layout.is_unsized() + ); if !layout.is_unsized() { return None; } - match *pointee_ty.kind() { + match *pointee_tail_ty.kind() { ty::Str | ty::Slice(_) => Some(FatPtrKind::Slice), ty::Dynamic(..) => Some(FatPtrKind::Dyn), - 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); - debug_assert!(unsized_field.is_unsized()); - fat_pointer_kind(cx, unsized_field.ty) - } ty::Foreign(_) => { // Assert that pointers to foreign types really are thin: debug_assert_eq!( - cx.size_of(cx.tcx.mk_imm_ptr(pointee_ty)), + cx.size_of(cx.tcx.mk_imm_ptr(pointee_tail_ty)), cx.size_of(cx.tcx.mk_imm_ptr(cx.tcx.types.u8)) ); None @@ -94,7 +90,10 @@ pub(crate) fn fat_pointer_kind<'ll, 'tcx>( _ => { // For all other pointee types we should already have returned None // at the beginning of the function. - panic!("fat_pointer_kind() - Encountered unexpected `pointee_ty`: {:?}", pointee_ty) + panic!( + "fat_pointer_kind() - Encountered unexpected `pointee_tail_ty`: {:?}", + pointee_tail_ty + ) } } } |
