]> git.proxmox.com Git - rustc.git/blame - src/test/incremental/spike-neg1.rs
New upstream version 1.28.0~beta.14+dfsg1
[rustc.git] / src / test / incremental / spike-neg1.rs
CommitLineData
5bcae85e
SL
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
94b46f34 12// `rustc_partition_reused` and `rustc_partition_codegened` tests.
5bcae85e
SL
13// Here we change and say that the `x` module will be reused (when in
14// 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_neg1", cfg="rpass2")]
24#![rustc_partition_reused(module="spike_neg1-x", cfg="rpass2")] // this is wrong!
25#![rustc_partition_reused(module="spike_neg1-y", cfg="rpass2")]
26
27mod 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
51mod y {
52 use x;
53
54 pub fn assert_sum() -> bool {
55 let x = x::new();
56 x::sum(&x) == 22
57 }
58}
59
60pub fn main() {
61 y::assert_sum();
62}