]> git.lizzy.rs Git - rust.git/blob - src/test/codegen-units/item-collection/instantiation-through-vtable.rs
Rollup merge of #105109 - rcvalle:rust-kcfi, r=bjorn3
[rust.git] / src / test / codegen-units / item-collection / instantiation-through-vtable.rs
1 //
2 // compile-flags:-Zprint-mono-items=eager -Zinline-in-all-cgus -Zmir-opt-level=0
3
4 #![deny(dead_code)]
5 #![feature(start)]
6
7 trait Trait {
8     fn foo(&self) -> u32;
9     fn bar(&self);
10 }
11
12 struct Struct<T> {
13     _a: T
14 }
15
16 impl<T> Trait for Struct<T> {
17     fn foo(&self) -> u32 { 0 }
18     fn bar(&self) {}
19 }
20
21 //~ MONO_ITEM fn start
22 #[start]
23 fn start(_: isize, _: *const *const u8) -> isize {
24     let s1 = Struct { _a: 0u32 };
25
26     //~ MONO_ITEM fn std::ptr::drop_in_place::<Struct<u32>> - shim(None) @@ instantiation_through_vtable-cgu.0[Internal]
27     //~ MONO_ITEM fn <Struct<u32> as Trait>::foo
28     //~ MONO_ITEM fn <Struct<u32> as Trait>::bar
29     let _ = &s1 as &Trait;
30
31     let s1 = Struct { _a: 0u64 };
32     //~ MONO_ITEM fn std::ptr::drop_in_place::<Struct<u64>> - shim(None) @@ instantiation_through_vtable-cgu.0[Internal]
33     //~ MONO_ITEM fn <Struct<u64> as Trait>::foo
34     //~ MONO_ITEM fn <Struct<u64> as Trait>::bar
35     let _ = &s1 as &Trait;
36
37     0
38 }