]> git.lizzy.rs Git - rust.git/blob - tests/ui/sepcomp/sepcomp-statics.rs
Rollup merge of #106321 - compiler-errors:delayed-bug-backtrace, r=Nilstrieb
[rust.git] / tests / ui / sepcomp / sepcomp-statics.rs
1 // run-pass
2 #![allow(dead_code)]
3 // compile-flags: -C codegen-units=3
4
5 // Test references to static items across compilation units.
6
7
8 fn pad() -> usize { 0 }
9
10 const ONE: usize = 1;
11
12 mod b {
13     // Separate compilation always switches to the LLVM module with the fewest
14     // instructions.  Make sure we have some instructions in this module so
15     // that `a` and `b` don't go into the same compilation unit.
16     fn pad() -> usize { 0 }
17
18     pub static THREE: usize = ::ONE + ::a::TWO;
19 }
20
21 mod a {
22     fn pad() -> usize { 0 }
23
24     pub const TWO: usize = ::ONE + ::ONE;
25 }
26
27 fn main() {
28     assert_eq!(ONE, 1);
29     assert_eq!(a::TWO, 2);
30     assert_eq!(b::THREE, 3);
31 }