// This test checks the debuginfo for the expected 3 vtables is generated for correct names and number // of entries. // Use the v0 symbol mangling scheme to codegen order independent of rustc version. // Unnamed items like shims are generated in lexicographical order of their symbol name and in the // legacy mangling scheme rustc version and generic parameters are both hashed into a single part // of the name, thus randomizing item order with respect to rustc version. // compile-flags: -Cdebuginfo=2 -Copt-level=0 -Csymbol-mangling-version=v0 // ignore-tidy-linelength // NONMSVC: !DIGlobalVariable(name: "::{vtable}" // MSVC: !DIGlobalVariable(name: "impl$::vtable$" // NONMSVC: !DIDerivedType(tag: DW_TAG_pointer_type, name: "*const ()", // MSVC: !DIDerivedType(tag: DW_TAG_pointer_type, name: "ptr_const$ >", // CHECK: !DISubrange(count: 5 // NONMSVC: !DIGlobalVariable(name: ">::{vtable}" // MSVC: !DIGlobalVariable(name: "impl$ >::vtable$" // CHECK: !DISubrange(count: 4 // NONMSVC: !DIGlobalVariable(name: "::{vtable}" // MSVC: !DIGlobalVariable(name: "impl$::vtable$" // CHECK: !DISubrange(count: 3 // NONMSVC: !DIGlobalVariable(name: ">)>>::{vtable}" // MSVC: !DIGlobalVariable(name: "impl$,assoc$ > > > > >, {{.*}}, {{.*}}, Some> > > >::vtable$" // NONMSVC: !DIGlobalVariable(name: " as core::ops::function::FnOnce<()>>::{vtable}" // MSVC: !DIGlobalVariable(name: "impl$, core::ops::function::FnOnce > >::vtable$ // NONMSVC: !DIGlobalVariable(name: " as core::ops::function::FnOnce<()>>::{vtable}" // MSVC: !DIGlobalVariable(name: "impl$, core::ops::function::FnOnce > >::vtable$ #![crate_type = "lib"] pub struct Foo; pub trait SomeTrait { fn method1(&self) -> u32; fn method2(&self) -> u32; } impl SomeTrait for Foo { fn method1(&self) -> u32 { 1 } fn method2(&self) -> u32 { 2 } } pub trait SomeTraitWithGenerics { fn method1(&self) -> (T, U); } impl SomeTraitWithGenerics for Foo { fn method1(&self) -> (u64, i8) { (1, 2) } } pub fn foo(x: &Foo) -> (u32, (u64, i8), &dyn Send) { let y: &dyn SomeTrait = x; 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 be computed. pub fn bar() -> Box)> { Box::new(|_x: Option<&dyn Fn()>| {}) } fn generic_closure(x: T) -> Box T> { Box::new(move || x) } pub fn instantiate_generic_closures() -> (Box u32>, Box bool>) { (generic_closure(1u32), generic_closure(false)) }