]> git.lizzy.rs Git - rust.git/blob - src/test/ui/dep-graph/dep-graph-struct-signature.rs
Rollup merge of #94577 - RalfJung:simd-miri, r=scottmcm
[rust.git] / src / test / ui / dep-graph / dep-graph-struct-signature.rs
1 // Test cases where a changing struct appears in the signature of fns
2 // and methods.
3
4 // incremental
5 // compile-flags: -Z query-dep-graph
6
7 #![feature(rustc_attrs)]
8 #![allow(dead_code)]
9 #![allow(unused_variables)]
10
11 fn main() { }
12
13 #[rustc_if_this_changed]
14 struct WillChange {
15     x: u32,
16     y: u32
17 }
18
19 struct WontChange {
20     x: u32,
21     y: u32
22 }
23
24 // these are valid dependencies
25 mod signatures {
26     use WillChange;
27
28     #[rustc_then_this_would_need(type_of)] //~ ERROR no path
29     #[rustc_then_this_would_need(associated_item)] //~ ERROR no path
30     #[rustc_then_this_would_need(trait_def)] //~ ERROR no path
31     trait Bar {
32         #[rustc_then_this_would_need(fn_sig)] //~ ERROR OK
33         fn do_something(x: WillChange);
34     }
35
36     #[rustc_then_this_would_need(fn_sig)] //~ ERROR OK
37     #[rustc_then_this_would_need(typeck)] //~ ERROR OK
38     fn some_fn(x: WillChange) { }
39
40     #[rustc_then_this_would_need(fn_sig)] //~ ERROR OK
41     #[rustc_then_this_would_need(typeck)] //~ ERROR OK
42     fn new_foo(x: u32, y: u32) -> WillChange {
43         WillChange { x: x, y: y }
44     }
45
46     #[rustc_then_this_would_need(type_of)] //~ ERROR OK
47     impl WillChange {
48         #[rustc_then_this_would_need(fn_sig)] //~ ERROR OK
49         #[rustc_then_this_would_need(typeck)] //~ ERROR OK
50         fn new(x: u32, y: u32) -> WillChange { loop { } }
51     }
52
53     #[rustc_then_this_would_need(type_of)] //~ ERROR OK
54     impl WillChange {
55         #[rustc_then_this_would_need(fn_sig)] //~ ERROR OK
56         #[rustc_then_this_would_need(typeck)] //~ ERROR OK
57         fn method(&self, x: u32) { }
58     }
59
60     struct WillChanges {
61         #[rustc_then_this_would_need(type_of)] //~ ERROR OK
62         x: WillChange,
63         #[rustc_then_this_would_need(type_of)] //~ ERROR OK
64         y: WillChange
65     }
66
67     // The fields change, not the type itself.
68     #[rustc_then_this_would_need(type_of)] //~ ERROR no path
69     fn indirect(x: WillChanges) { }
70 }
71
72 mod invalid_signatures {
73     use WontChange;
74
75     #[rustc_then_this_would_need(type_of)] //~ ERROR no path
76     trait A {
77         #[rustc_then_this_would_need(fn_sig)] //~ ERROR no path
78         fn do_something_else_twice(x: WontChange);
79     }
80
81     #[rustc_then_this_would_need(fn_sig)] //~ ERROR no path
82     fn b(x: WontChange) { }
83
84     #[rustc_then_this_would_need(fn_sig)] //~ ERROR no path from `WillChange`
85     #[rustc_then_this_would_need(typeck)] //~ ERROR no path from `WillChange`
86     fn c(x: u32) { }
87 }