]>
git.proxmox.com Git - rustc.git/blob - src/test/codegen/debug-vtable.rs
1 // compile-flags: -Cdebuginfo=2 -Copt-level=0 -Ccodegen-units=1
2 // ignore-tidy-linelength
4 // This test checks the debuginfo for the expected 3 vtables is generated for correct names and number
7 // NONMSVC-LABEL: !DIGlobalVariable(name: "<debug_vtable::Foo as debug_vtable::SomeTrait>::{vtable}"
8 // MSVC-LABEL: !DIGlobalVariable(name: "impl$<debug_vtable::Foo, debug_vtable::SomeTrait>::vtable$"
9 // NONMSVC: !DIDerivedType(tag: DW_TAG_pointer_type, name: "*const ()",
10 // MSVC: !DIDerivedType(tag: DW_TAG_pointer_type, name: "ptr_const$<tuple$<> >",
11 // CHECK: !DISubrange(count: 5
13 // NONMSVC-LABEL: !DIGlobalVariable(name: "<debug_vtable::Foo as debug_vtable::SomeTraitWithGenerics<u64, i8>>::{vtable}"
14 // MSVC-LABEL: !DIGlobalVariable(name: "impl$<debug_vtable::Foo, debug_vtable::SomeTraitWithGenerics<u64,i8> >::vtable$"
15 // CHECK: !DISubrange(count: 4
17 // NONMSVC-LABEL: !DIGlobalVariable(name: "<debug_vtable::Foo as _>::{vtable}"
18 // MSVC-LABEL: !DIGlobalVariable(name: "impl$<debug_vtable::Foo, _>::vtable$"
19 // CHECK: !DISubrange(count: 3
21 // NONMSVC-LABEL: !DIGlobalVariable(name: "<debug_vtable::bar::{closure#0} as core::ops::function::FnOnce<(core::option::Option<&dyn core::ops::function::Fn<(), Output=()>>)>>::{vtable}"
22 // 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$"
24 #![crate_type = "lib"]
29 fn method1(&self) -> u32;
30 fn method2(&self) -> u32;
33 impl SomeTrait
for Foo
{
34 fn method1(&self) -> u32 { 1 }
35 fn method2(&self) -> u32 { 2 }
38 pub trait SomeTraitWithGenerics
<T
, U
> {
39 fn method1(&self) -> (T
, U
);
42 impl SomeTraitWithGenerics
<u64, i8> for Foo
{
43 fn method1(&self) -> (u64, i8) { (1, 2) }
46 pub fn foo(x
: &Foo
) -> (u32, (u64, i8), &dyn Send
) {
47 let y
: &dyn SomeTrait
= x
;
48 let z
: &dyn SomeTraitWithGenerics
<u64, i8> = x
;
49 (y
.method1(), z
.method1(), x
as &dyn Send
)
52 // Constructing the debuginfo name for the FnOnce vtable below initially caused an ICE on MSVC
53 // because the trait type contains a late bound region that needed to be erased before the type
54 // layout for the niche enum `Option<&dyn Fn()>` could be computed.
55 pub fn bar() -> Box
<dyn FnOnce(Option
<&dyn Fn()>)> {
56 Box
::new(|_x
: Option
<&dyn Fn()>| {}
)