]> git.proxmox.com Git - rustc.git/blob - src/test/incremental/spike-neg2.rs
New upstream version 1.66.0+dfsg1
[rustc.git] / src / test / incremental / spike-neg2.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 `y` module will be codegened (when
4 // in 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_neg2", cfg="rpass2")]
14 #![rustc_partition_codegened(module="spike_neg2-x", cfg="rpass2")]
15 #![rustc_partition_codegened(module="spike_neg2-y", cfg="rpass2")] // this is wrong!
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 }