]>
Commit | Line | Data |
---|---|---|
9cc50fc6 SL |
1 | // Copyright 2012-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 | // Test cases where a changing struct appears in the signature of fns | |
12 | // and methods. | |
13 | ||
54a0048b | 14 | // compile-flags: -Z query-dep-graph |
9cc50fc6 SL |
15 | |
16 | #![feature(rustc_attrs)] | |
17 | #![allow(dead_code)] | |
18 | #![allow(unused_variables)] | |
19 | ||
20 | fn main() { } | |
21 | ||
22 | #[rustc_if_this_changed] | |
23 | struct WillChange { | |
24 | x: u32, | |
25 | y: u32 | |
26 | } | |
27 | ||
28 | struct WontChange { | |
29 | x: u32, | |
30 | y: u32 | |
31 | } | |
32 | ||
33 | // these are valid dependencies | |
34 | mod signatures { | |
35 | use WillChange; | |
36 | ||
37 | #[rustc_then_this_would_need(ItemSignature)] //~ ERROR OK | |
38 | #[rustc_then_this_would_need(CollectItem)] //~ ERROR OK | |
39 | trait Bar { | |
40 | fn do_something(x: WillChange); | |
41 | } | |
42 | ||
43 | #[rustc_then_this_would_need(ItemSignature)] //~ ERROR OK | |
44 | #[rustc_then_this_would_need(CollectItem)] //~ ERROR OK | |
45 | fn some_fn(x: WillChange) { } | |
46 | ||
47 | #[rustc_then_this_would_need(ItemSignature)] //~ ERROR OK | |
48 | #[rustc_then_this_would_need(CollectItem)] //~ ERROR OK | |
49 | fn new_foo(x: u32, y: u32) -> WillChange { | |
50 | WillChange { x: x, y: y } | |
51 | } | |
52 | ||
53 | #[rustc_then_this_would_need(ItemSignature)] //~ ERROR OK | |
54 | #[rustc_then_this_would_need(CollectItem)] //~ ERROR OK | |
55 | impl WillChange { | |
56 | fn new(x: u32, y: u32) -> WillChange { loop { } } | |
57 | } | |
58 | ||
59 | #[rustc_then_this_would_need(ItemSignature)] //~ ERROR OK | |
60 | #[rustc_then_this_would_need(CollectItem)] //~ ERROR OK | |
61 | impl WillChange { | |
62 | fn method(&self, x: u32) { } | |
63 | } | |
64 | ||
65 | #[rustc_then_this_would_need(ItemSignature)] //~ ERROR OK | |
66 | #[rustc_then_this_would_need(CollectItem)] //~ ERROR OK | |
67 | struct WillChanges { | |
68 | x: WillChange, | |
69 | y: WillChange | |
70 | } | |
71 | ||
72 | #[rustc_then_this_would_need(ItemSignature)] //~ ERROR OK | |
73 | #[rustc_then_this_would_need(CollectItem)] //~ ERROR OK | |
74 | fn indirect(x: WillChanges) { } | |
75 | } | |
76 | ||
9cc50fc6 SL |
77 | mod invalid_signatures { |
78 | use WontChange; | |
79 | ||
7453a54e SL |
80 | #[rustc_then_this_would_need(ItemSignature)] //~ ERROR no path |
81 | #[rustc_then_this_would_need(CollectItem)] //~ ERROR no path | |
9cc50fc6 SL |
82 | trait A { |
83 | fn do_something_else_twice(x: WontChange); | |
84 | } | |
85 | ||
7453a54e SL |
86 | #[rustc_then_this_would_need(ItemSignature)] //~ ERROR no path |
87 | #[rustc_then_this_would_need(CollectItem)] //~ ERROR no path | |
9cc50fc6 SL |
88 | fn b(x: WontChange) { } |
89 | ||
90 | #[rustc_then_this_would_need(ItemSignature)] //~ ERROR no path from `WillChange` | |
91 | #[rustc_then_this_would_need(CollectItem)] //~ ERROR no path from `WillChange` | |
92 | fn c(x: u32) { } | |
93 | } | |
94 |