rust/tests/ui/sepcomp/sepcomp-fns-backwards.rs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

34 lines
626 B
Rust
Raw Normal View History

// run-pass
#![allow(dead_code)]
2014-08-01 22:45:24 +00:00
// compile-flags: -C codegen-units=3
2018-05-08 13:10:16 +00:00
// Test references to items that haven't been codegened yet.
2014-08-01 22:45:24 +00:00
// Generate some code in the first compilation unit before declaring any
// modules. This ensures that the first module doesn't go into the same
// compilation unit as the top-level module.
fn pad() -> usize { 0 }
2014-08-01 22:45:24 +00:00
mod b {
pub fn three() -> usize {
2014-08-01 22:45:24 +00:00
::one() + ::a::two()
}
}
mod a {
pub fn two() -> usize {
2014-08-01 22:45:24 +00:00
::one() + ::one()
}
}
fn one() -> usize {
2014-08-01 22:45:24 +00:00
1
}
fn main() {
assert_eq!(one(), 1);
assert_eq!(a::two(), 2);
assert_eq!(b::three(), 3);
}