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