]>
git.proxmox.com Git - rustc.git/blob - src/test/codegen-units/partitioning/vtable-through-const.rs
1 // Copyright 2016 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
11 // ignore-tidy-linelength
13 // We specify -Z incremental here because we want to test the partitioning for
14 // incremental compilation
15 // compile-flags:-Zprint-mono-items=lazy -Zincremental=tmp/partitioning-tests/vtable-through-const
16 // compile-flags:-Zinline-in-all-cgus
18 // This test case makes sure, that references made through constants are
19 // recorded properly in the InliningMap.
25 fn do_something(&self) {}
26 fn do_something_else(&self) {}
29 impl Trait1
for u32 {}
31 pub trait Trait1Gen
<T
> {
32 fn do_something(&self, x
: T
) -> T
;
33 fn do_something_else(&self, x
: T
) -> T
;
36 impl<T
> Trait1Gen
<T
> for u32 {
37 fn do_something(&self, x
: T
) -> T { x }
38 fn do_something_else(&self, x
: T
) -> T { x }
41 fn id
<T
>(x
: T
) -> T { x }
43 // These are referenced, so they produce mono-items (see start())
44 pub const TRAIT1_REF
: &'
static Trait1
= &0u32 as &Trait1
;
45 pub const TRAIT1_GEN_REF
: &'
static Trait1Gen
<u8> = &0u32 as &Trait1Gen
<u8>;
46 pub const ID_CHAR
: fn(char) -> char = id
::<char>;
51 fn do_something(&self) {}
52 fn do_something_else(&self) {}
55 impl Trait2
for u32 {}
57 pub trait Trait2Gen
<T
> {
58 fn do_something(&self, x
: T
) -> T
;
59 fn do_something_else(&self, x
: T
) -> T
;
62 impl<T
> Trait2Gen
<T
> for u32 {
63 fn do_something(&self, x
: T
) -> T { x }
64 fn do_something_else(&self, x
: T
) -> T { x }
67 // These are not referenced, so they do not produce mono-items
68 pub const TRAIT2_REF
: &'
static Trait2
= &0u32 as &Trait2
;
69 pub const TRAIT2_GEN_REF
: &'
static Trait2Gen
<u8> = &0u32 as &Trait2Gen
<u8>;
70 pub const ID_I64
: fn(i64) -> i64 = id
::<i64>;
73 //~ MONO_ITEM fn vtable_through_const::start[0]
75 fn start(_
: isize, _
: *const *const u8) -> isize {
76 //~ MONO_ITEM fn core::ptr[0]::drop_in_place[0]<u32> @@ vtable_through_const[Internal]
78 // Since Trait1::do_something() is instantiated via its default implementation,
79 // it is considered a generic and is instantiated here only because it is
80 // referenced in this module.
81 //~ MONO_ITEM fn vtable_through_const::mod1[0]::Trait1[0]::do_something_else[0]<u32> @@ vtable_through_const-mod1.volatile[External]
83 // Although it is never used, Trait1::do_something_else() has to be
84 // instantiated locally here too, otherwise the <&u32 as &Trait1> vtable
85 // could not be fully constructed.
86 //~ MONO_ITEM fn vtable_through_const::mod1[0]::Trait1[0]::do_something[0]<u32> @@ vtable_through_const-mod1.volatile[External]
87 mod1
::TRAIT1_REF
.do_something();
90 //~ MONO_ITEM fn vtable_through_const::mod1[0]::{{impl}}[1]::do_something[0]<u8> @@ vtable_through_const-mod1.volatile[External]
91 //~ MONO_ITEM fn vtable_through_const::mod1[0]::{{impl}}[1]::do_something_else[0]<u8> @@ vtable_through_const-mod1.volatile[External]
92 mod1
::TRAIT1_GEN_REF
.do_something(0u8);
94 //~ MONO_ITEM fn vtable_through_const::mod1[0]::id[0]<char> @@ vtable_through_const-mod1.volatile[External]