]> git.lizzy.rs Git - rust.git/blob - src/test/incremental/spike.rs
Auto merge of #54497 - ralexstokes:stabilize_pattern_parentheses, r=nikomatsakis
[rust.git] / src / test / incremental / spike.rs
1 // Copyright 2014 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 // A first "spike" for incremental compilation: here, we change the
12 // content of the `make` function, and we find that we can reuse the
13 // `y` module entirely (but not the `x` module).
14
15 // revisions:rpass1 rpass2
16 // compile-flags: -Z query-dep-graph
17
18 #![feature(rustc_attrs)]
19
20 #![rustc_partition_reused(module="spike", cfg="rpass2")]
21 #![rustc_partition_codegened(module="spike-x", cfg="rpass2")]
22 #![rustc_partition_reused(module="spike-y", cfg="rpass2")]
23
24 mod x {
25     pub struct X {
26         x: u32, y: u32,
27     }
28
29     #[cfg(rpass1)]
30     fn make() -> X {
31         X { x: 22, y: 0 }
32     }
33
34     #[cfg(rpass2)]
35     fn make() -> X {
36         X { x: 11, y: 11 }
37     }
38
39     pub fn new() -> X {
40         make()
41     }
42
43     pub fn sum(x: &X) -> u32 {
44         x.x + x.y
45     }
46 }
47
48 mod y {
49     use x;
50
51     pub fn assert_sum() -> bool {
52         let x = x::new();
53         x::sum(&x) == 22
54     }
55 }
56
57 pub fn main() {
58     y::assert_sum();
59 }