1 // ignore-tidy-linelength
3 // We specify -C incremental here because we want to test the partitioning for
4 // incremental compilation
5 // compile-flags:-Zprint-mono-items=lazy -Cincremental=tmp/partitioning-tests/vtable-through-const
6 // compile-flags:-Zinline-in-all-cgus
8 // This test case makes sure, that references made through constants are
9 // recorded properly in the InliningMap.
15 fn do_something(&self) {}
16 fn do_something_else(&self) {}
19 impl Trait1 for u32 {}
21 pub trait Trait1Gen<T> {
22 fn do_something(&self, x: T) -> T;
23 fn do_something_else(&self, x: T) -> T;
26 impl<T> Trait1Gen<T> for u32 {
27 fn do_something(&self, x: T) -> T { x }
28 fn do_something_else(&self, x: T) -> T { x }
31 //~ MONO_ITEM fn mod1::id::<i64> @@ vtable_through_const-mod1.volatile[Internal]
32 fn id<T>(x: T) -> T { x }
34 // These are referenced, so they produce mono-items (see start())
35 pub const TRAIT1_REF: &'static Trait1 = &0u32 as &Trait1;
36 pub const TRAIT1_GEN_REF: &'static Trait1Gen<u8> = &0u32 as &Trait1Gen<u8>;
37 pub const ID_CHAR: fn(char) -> char = id::<char>;
42 fn do_something(&self) {}
43 fn do_something_else(&self) {}
46 //~ MONO_ITEM fn <u32 as mod1::Trait2>::do_something @@ vtable_through_const-mod1.volatile[Internal]
47 //~ MONO_ITEM fn <u32 as mod1::Trait2>::do_something_else @@ vtable_through_const-mod1.volatile[Internal]
48 impl Trait2 for u32 {}
50 pub trait Trait2Gen<T> {
51 fn do_something(&self, x: T) -> T;
52 fn do_something_else(&self, x: T) -> T;
55 impl<T> Trait2Gen<T> for u32 {
56 fn do_something(&self, x: T) -> T { x }
57 fn do_something_else(&self, x: T) -> T { x }
60 // These are not referenced, so they do not produce mono-items
61 pub const TRAIT2_REF: &'static Trait2 = &0u32 as &Trait2;
62 pub const TRAIT2_GEN_REF: &'static Trait2Gen<u8> = &0u32 as &Trait2Gen<u8>;
63 pub const ID_I64: fn(i64) -> i64 = id::<i64>;
66 //~ MONO_ITEM fn start
68 fn start(_: isize, _: *const *const u8) -> isize {
69 //~ MONO_ITEM fn std::intrinsics::drop_in_place::<u32> - shim(None) @@ vtable_through_const[Internal]
71 // Since Trait1::do_something() is instantiated via its default implementation,
72 // it is considered a generic and is instantiated here only because it is
73 // referenced in this module.
74 //~ MONO_ITEM fn <u32 as mod1::Trait1>::do_something_else @@ vtable_through_const-mod1.volatile[External]
76 // Although it is never used, Trait1::do_something_else() has to be
77 // instantiated locally here too, otherwise the <&u32 as &Trait1> vtable
78 // could not be fully constructed.
79 //~ MONO_ITEM fn <u32 as mod1::Trait1>::do_something @@ vtable_through_const-mod1.volatile[External]
80 mod1::TRAIT1_REF.do_something();
83 //~ MONO_ITEM fn <u32 as mod1::Trait1Gen<u8>>::do_something @@ vtable_through_const-mod1.volatile[External]
84 //~ MONO_ITEM fn <u32 as mod1::Trait1Gen<u8>>::do_something_else @@ vtable_through_const-mod1.volatile[External]
85 //~ MONO_ITEM fn <u32 as mod1::Trait2Gen<u8>>::do_something @@ vtable_through_const-mod1.volatile[Internal]
86 //~ MONO_ITEM fn <u32 as mod1::Trait2Gen<u8>>::do_something_else @@ vtable_through_const-mod1.volatile[Internal]
87 mod1::TRAIT1_GEN_REF.do_something(0u8);
89 //~ MONO_ITEM fn mod1::id::<char> @@ vtable_through_const-mod1.volatile[External]