diff options
| author | bors <bors@rust-lang.org> | 2021-10-20 14:37:48 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2021-10-20 14:37:48 +0000 |
| commit | 3d71e749a244890cd370d49963e747cf92f4a037 (patch) | |
| tree | 91367ad6fd885986b7bda1dfd975bc2a1ccb2751 /src/test/codegen | |
| parent | 6162529a01473bbb2427fa27354cbafc3c514eee (diff) | |
| parent | 5929cf0d67c0678e599190007c6e62be6a6839f7 (diff) | |
| download | rust-3d71e749a244890cd370d49963e747cf92f4a037.tar.gz rust-3d71e749a244890cd370d49963e747cf92f4a037.zip | |
Auto merge of #90050 - michaelwoerister:fix-vtable-debug-name-crash-90019, r=wesleywiser
Erase late-bound regions before computing vtable debuginfo name. Fixes #90019. The `msvc_enum_fallback()` for computing enum type names needs to access the memory layout of niche enums in order to determine the type name. `compute_debuginfo_vtable_name()` did not properly erase regions before computing type names which made memory layout computation ICE when encountering un-erased regions. r? `@wesleywiser`
Diffstat (limited to 'src/test/codegen')
| -rw-r--r-- | src/test/codegen/debug-vtable.rs | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/test/codegen/debug-vtable.rs b/src/test/codegen/debug-vtable.rs index 851d68da5ee..1c8cc61f204 100644 --- a/src/test/codegen/debug-vtable.rs +++ b/src/test/codegen/debug-vtable.rs @@ -18,6 +18,9 @@ // MSVC-LABEL: !DIGlobalVariable(name: "impl$<debug_vtable::Foo, _>::vtable$" // CHECK: !DISubrange(count: 3 +// NONMSVC-LABEL: !DIGlobalVariable(name: "<debug_vtable::bar::{closure#0} as core::ops::function::FnOnce<(core::option::Option<&dyn core::ops::function::Fn<(), Output=()>>)>>::{vtable}" +// MSVC-LABEL: !DIGlobalVariable(name: "impl$<debug_vtable::bar::closure$0, core::ops::function::FnOnce<tuple$<enum$<core::option::Option<ref$<dyn$<core::ops::function::Fn<tuple$<>,assoc$<Output,tuple$<> > > > > >, {{.*}}, {{.*}}, 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<u64, i8> = 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 be computed. +pub fn bar() -> Box<dyn FnOnce(Option<&dyn Fn()>)> { + Box::new(|_x: Option<&dyn Fn()>| {}) +} |
