]> git.lizzy.rs Git - rust.git/blob - tests/incremental/spike-neg1.rs
Rollup merge of #107524 - cjgillot:both-storage, r=RalfJung
[rust.git] / tests / incremental / spike-neg1.rs
1 // A variant of the first "spike" test that serves to test the
2 // `rustc_partition_reused` and `rustc_partition_codegened` tests.
3 // Here we change and say that the `x` module will be reused (when in
4 // fact it will not), and then indicate that the test itself
5 // should-fail (because an error will be reported, and hence the
6 // revision rpass2 will not compile, despite being named rpass).
7
8 // revisions:rpass1 rpass2
9 // should-fail
10
11 #![feature(rustc_attrs)]
12
13 #![rustc_partition_reused(module="spike_neg1", cfg="rpass2")]
14 #![rustc_partition_reused(module="spike_neg1-x", cfg="rpass2")] // this is wrong!
15 #![rustc_partition_reused(module="spike_neg1-y", cfg="rpass2")]
16
17 mod x {
18     pub struct X {
19         x: u32, y: u32,
20     }
21
22     #[cfg(rpass1)]
23     fn make() -> X {
24         X { x: 22, y: 0 }
25     }
26
27     #[cfg(rpass2)]
28     fn make() -> X {
29         X { x: 11, y: 11 }
30     }
31
32     pub fn new() -> X {
33         make()
34     }
35
36     pub fn sum(x: &X) -> u32 {
37         x.x + x.y
38     }
39 }
40
41 mod y {
42     use x;
43
44     pub fn assert_sum() -> bool {
45         let x = x::new();
46         x::sum(&x) == 22
47     }
48 }
49
50 pub fn main() {
51     y::assert_sum();
52 }