diff options
| author | bors <bors@rust-lang.org> | 2021-10-11 04:31:47 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2021-10-11 04:31:47 +0000 |
| commit | 9a757817c352801de8b0593728f8aee21e23cd53 (patch) | |
| tree | 42c5d573cee81a5de4b243cbe9d52eddeda23a97 /compiler/rustc_codegen_ssa/src/traits | |
| parent | 1ddd4e6d7ed446934abd428a08e18535faef5e03 (diff) | |
| parent | 61c5a6d644e9e5c1995c33a2b07ab251702848ac (diff) | |
| download | rust-9a757817c352801de8b0593728f8aee21e23cd53.tar.gz rust-9a757817c352801de8b0593728f8aee21e23cd53.zip | |
Auto merge of #89597 - michaelwoerister:improve-vtable-debuginfo, r=wesleywiser
Create more accurate debuginfo for vtables. Before this PR all vtables would have the same name (`"vtable"`) in debuginfo. Now they get an unambiguous name that identifies the implementing type and the trait that is being implemented. This is only one of several possible improvements: - This PR describes vtables as arrays of `*const u8` pointers. It would nice to describe them as structs where function pointer is represented by a field with a name indicative of the method it maps to. However, this requires coming up with a naming scheme that avoids clashes between methods with the same name (which is possible if the vtable contains multiple traits). - The PR does not update the debuginfo we generate for the vtable-pointer field in a fat `dyn` pointer. Right now there does not seem to be an easy way of getting ahold of a vtable-layout without also knowing the concrete self-type of a trait object. r? `@wesleywiser`
Diffstat (limited to 'compiler/rustc_codegen_ssa/src/traits')
| -rw-r--r-- | compiler/rustc_codegen_ssa/src/traits/debuginfo.rs | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/compiler/rustc_codegen_ssa/src/traits/debuginfo.rs b/compiler/rustc_codegen_ssa/src/traits/debuginfo.rs index 3e66d711d2e..e700afc448f 100644 --- a/compiler/rustc_codegen_ssa/src/traits/debuginfo.rs +++ b/compiler/rustc_codegen_ssa/src/traits/debuginfo.rs @@ -1,13 +1,18 @@ use super::BackendTypes; use crate::mir::debuginfo::{FunctionDebugContext, VariableKind}; use rustc_middle::mir; -use rustc_middle::ty::{Instance, Ty}; +use rustc_middle::ty::{Instance, PolyExistentialTraitRef, Ty}; use rustc_span::{SourceFile, Span, Symbol}; use rustc_target::abi::call::FnAbi; use rustc_target::abi::Size; pub trait DebugInfoMethods<'tcx>: BackendTypes { - fn create_vtable_metadata(&self, ty: Ty<'tcx>, vtable: Self::Value); + fn create_vtable_metadata( + &self, + ty: Ty<'tcx>, + trait_ref: Option<PolyExistentialTraitRef<'tcx>>, + vtable: Self::Value, + ); /// Creates the function-specific debug context. /// |
