]> git.proxmox.com Git - rustc.git/blob - src/test/incremental/spike-neg2.rs
New upstream version 1.12.0+dfsg1
[rustc.git] / src / test / incremental / spike-neg2.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 variant of the first "spike" test that serves to test the
12 // `rustc_partition_reused` and `rustc_partition_translated` tests.
13 // Here we change and say that the `y` module will be translated (when
14 // in fact it will not), and then indicate that the test itself
15 // should-fail (because an error will be reported, and hence the
16 // revision rpass2 will not compile, despite being named rpass).
17
18 // revisions:rpass1 rpass2
19 // should-fail
20
21 #![feature(rustc_attrs)]
22
23 #![rustc_partition_reused(module="spike_neg2", cfg="rpass2")]
24 #![rustc_partition_translated(module="spike_neg2-x", cfg="rpass2")]
25 #![rustc_partition_translated(module="spike_neg2-y", cfg="rpass2")] // this is wrong!
26
27 mod x {
28 pub struct X {
29 x: u32, y: u32,
30 }
31
32 #[cfg(rpass1)]
33 fn make() -> X {
34 X { x: 22, y: 0 }
35 }
36
37 #[cfg(rpass2)]
38 fn make() -> X {
39 X { x: 11, y: 11 }
40 }
41
42 pub fn new() -> X {
43 make()
44 }
45
46 pub fn sum(x: &X) -> u32 {
47 x.x + x.y
48 }
49 }
50
51 mod y {
52 use x;
53
54 pub fn assert_sum() -> bool {
55 let x = x::new();
56 x::sum(&x) == 22
57 }
58 }
59
60 pub fn main() {
61 y::assert_sum();
62 }