From bf39d86e0f34c439306f9dff9d01ca15792b5fd5 Mon Sep 17 00:00:00 2001 From: Michael Woerister Date: Tue, 19 Oct 2021 11:46:51 +0200 Subject: [PATCH 1/2] Erase late-bound regions before computing vtable debuginfo name. --- .../rustc_codegen_ssa/src/debuginfo/type_names.rs | 11 ++++------- src/test/codegen/debug-vtable.rs | 10 ++++++++++ 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/compiler/rustc_codegen_ssa/src/debuginfo/type_names.rs b/compiler/rustc_codegen_ssa/src/debuginfo/type_names.rs index 609316ea69fe5..accb54e464553 100644 --- a/compiler/rustc_codegen_ssa/src/debuginfo/type_names.rs +++ b/compiler/rustc_codegen_ssa/src/debuginfo/type_names.rs @@ -480,14 +480,11 @@ pub fn compute_debuginfo_vtable_name<'tcx>( } if let Some(trait_ref) = trait_ref { - push_item_name(tcx, trait_ref.skip_binder().def_id, true, &mut vtable_name); + let trait_ref = + tcx.normalize_erasing_late_bound_regions(ty::ParamEnv::reveal_all(), trait_ref); + push_item_name(tcx, trait_ref.def_id, true, &mut vtable_name); visited.clear(); - push_generic_params_internal( - tcx, - trait_ref.skip_binder().substs, - &mut vtable_name, - &mut visited, - ); + push_generic_params_internal(tcx, trait_ref.substs, &mut vtable_name, &mut visited); } else { vtable_name.push_str("_"); } diff --git a/src/test/codegen/debug-vtable.rs b/src/test/codegen/debug-vtable.rs index 851d68da5ee62..5f68da2b6b044 100644 --- a/src/test/codegen/debug-vtable.rs +++ b/src/test/codegen/debug-vtable.rs @@ -18,6 +18,9 @@ // MSVC-LABEL: !DIGlobalVariable(name: "impl$::vtable$" // CHECK: !DISubrange(count: 3 +// NONMSVC-LABEL: !DIGlobalVariable(name: ">)>>::{vtable}" +// MSVC-LABEL: !DIGlobalVariable(name: "impl$,assoc$ > > > > >, {{.*}}, {{.*}}, Some> > > >::vtable$" + #![crate_type = "lib"] pub struct Foo; @@ -45,3 +48,10 @@ pub fn foo(x: &Foo) -> (u32, (u64, i8), &dyn Send) { let z: &dyn SomeTraitWithGenerics = x; (y.method1(), z.method1(), x as &dyn Send) } + +// Constructing the debuginfo name for the FnOnce vtable below initially caused an ICE on MSVC +// because the trait type contains a late bound region that needed to be erased before the type +// layout for the niche enum `Option<&dyn Fn()>` could can be computed. +pub fn bar() -> Box)> { + Box::new(|_x: Option<&dyn Fn()>| {}) +} From 5929cf0d67c0678e599190007c6e62be6a6839f7 Mon Sep 17 00:00:00 2001 From: Wesley Wiser Date: Tue, 19 Oct 2021 11:36:21 -0400 Subject: [PATCH 2/2] Update src/test/codegen/debug-vtable.rs Co-authored-by: r00ster --- src/test/codegen/debug-vtable.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/codegen/debug-vtable.rs b/src/test/codegen/debug-vtable.rs index 5f68da2b6b044..1c8cc61f204dd 100644 --- a/src/test/codegen/debug-vtable.rs +++ b/src/test/codegen/debug-vtable.rs @@ -51,7 +51,7 @@ pub fn foo(x: &Foo) -> (u32, (u64, i8), &dyn Send) { // Constructing the debuginfo name for the FnOnce vtable below initially caused an ICE on MSVC // because the trait type contains a late bound region that needed to be erased before the type -// layout for the niche enum `Option<&dyn Fn()>` could can be computed. +// layout for the niche enum `Option<&dyn Fn()>` could be computed. pub fn bar() -> Box)> { Box::new(|_x: Option<&dyn Fn()>| {}) }