]> git.lizzy.rs Git - rust.git/blob - src/test/run-pass/sepcomp-statics.rs
Auto merge of #28816 - petrochenkov:unistruct, r=nrc
[rust.git] / src / test / run-pass / sepcomp-statics.rs
1 // Copyright 2012 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.
4 //
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.
10
11 // ignore-bitrig
12 // compile-flags: -C codegen-units=3
13
14 // Test references to static items across compilation units.
15
16
17 fn pad() -> usize { 0 }
18
19 const ONE: usize = 1;
20
21 mod b {
22     // Separate compilation always switches to the LLVM module with the fewest
23     // instructions.  Make sure we have some instructions in this module so
24     // that `a` and `b` don't go into the same compilation unit.
25     fn pad() -> usize { 0 }
26
27     pub static THREE: usize = ::ONE + ::a::TWO;
28 }
29
30 mod a {
31     fn pad() -> usize { 0 }
32
33     pub const TWO: usize = ::ONE + ::ONE;
34 }
35
36 fn main() {
37     assert_eq!(ONE, 1);
38     assert_eq!(a::TWO, 2);
39     assert_eq!(b::THREE, 3);
40 }