]> git.proxmox.com Git - rustc.git/blob - tests/ui/sepcomp/sepcomp-fns.rs
New upstream version 1.68.2+dfsg1
[rustc.git] / tests / ui / sepcomp / sepcomp-fns.rs
1 // run-pass
2 // compile-flags: -C codegen-units=3
3
4 // Test basic separate compilation functionality. The functions should be able
5 // to call each other even though they will be placed in different compilation
6 // units.
7
8 // Generate some code in the first compilation unit before declaring any
9 // modules. This ensures that the first module doesn't go into the same
10 // compilation unit as the top-level module.
11
12 fn one() -> usize { 1 }
13
14 mod a {
15 pub fn two() -> usize {
16 ::one() + ::one()
17 }
18 }
19
20 mod b {
21 pub fn three() -> usize {
22 ::one() + ::a::two()
23 }
24 }
25
26 fn main() {
27 assert_eq!(one(), 1);
28 assert_eq!(a::two(), 2);
29 assert_eq!(b::three(), 3);
30 }