]> git.lizzy.rs Git - rust.git/blob - tests/incremental/spike.rs
Move /src/test to /tests
[rust.git] / tests / incremental / spike.rs
1 // A first "spike" for incremental compilation: here, we change the
2 // content of the `make` function, and we find that we can reuse the
3 // `y` module entirely (but not the `x` module).
4
5 // revisions:rpass1 rpass2
6 // compile-flags: -Z query-dep-graph
7
8 #![feature(rustc_attrs)]
9
10 #![rustc_partition_reused(module="spike", cfg="rpass2")]
11 #![rustc_partition_codegened(module="spike-x", cfg="rpass2")]
12 #![rustc_partition_reused(module="spike-y", cfg="rpass2")]
13
14 mod x {
15     pub struct X {
16         x: u32, y: u32,
17     }
18
19     #[cfg(rpass1)]
20     fn make() -> X {
21         X { x: 22, y: 0 }
22     }
23
24     #[cfg(rpass2)]
25     fn make() -> X {
26         X { x: 11, y: 11 }
27     }
28
29     pub fn new() -> X {
30         make()
31     }
32
33     pub fn sum(x: &X) -> u32 {
34         x.x + x.y
35     }
36 }
37
38 mod y {
39     use x;
40
41     pub fn assert_sum() -> bool {
42         let x = x::new();
43         x::sum(&x) == 22
44     }
45 }
46
47 pub fn main() {
48     y::assert_sum();
49 }