]> git.lizzy.rs Git - rust.git/blob - src/test/incremental/hashes/closure_expressions.rs
Auto merge of #95884 - cjgillot:assoc-item, r=lcnr
[rust.git] / src / test / incremental / hashes / closure_expressions.rs
1 // This test case tests the incremental compilation hash (ICH) implementation
2 // for closure expression.
3
4 // The general pattern followed here is: Change one thing between rev1 and rev2
5 // and make sure that the hash has changed, then change nothing between rev2 and
6 // rev3 and make sure that the hash has not changed.
7
8 // build-pass (FIXME(62277): could be check-pass?)
9 // revisions: cfail1 cfail2 cfail3 cfail4 cfail5 cfail6
10 // compile-flags: -Z query-dep-graph -O
11 // [cfail1]compile-flags: -Zincremental-ignore-spans
12 // [cfail2]compile-flags: -Zincremental-ignore-spans
13 // [cfail3]compile-flags: -Zincremental-ignore-spans
14 // [cfail4]compile-flags: -Zincremental-relative-spans
15 // [cfail5]compile-flags: -Zincremental-relative-spans
16 // [cfail6]compile-flags: -Zincremental-relative-spans
17
18 #![allow(warnings)]
19 #![feature(rustc_attrs)]
20 #![crate_type="rlib"]
21
22
23 // Change closure body
24 #[cfg(any(cfail1,cfail4))]
25 pub fn change_closure_body() {
26     let _ = || 1u32;
27 }
28
29 #[cfg(not(any(cfail1,cfail4)))]
30 #[rustc_clean(cfg="cfail2", except="hir_owner_nodes")]
31 #[rustc_clean(cfg="cfail3")]
32 #[rustc_clean(cfg="cfail5", except="hir_owner_nodes")]
33 #[rustc_clean(cfg="cfail6")]
34 pub fn change_closure_body() {
35     let _ = || 3u32;
36 }
37
38
39
40 // Add parameter
41 #[cfg(any(cfail1,cfail4))]
42 pub fn add_parameter() {
43     let x = 0u32;
44     let _ = |      | x + 1;
45 }
46
47 #[cfg(not(any(cfail1,cfail4)))]
48 #[rustc_clean(cfg="cfail2", except="hir_owner_nodes, optimized_mir, typeck")]
49 #[rustc_clean(cfg="cfail3")]
50 #[rustc_clean(cfg="cfail5", except="hir_owner_nodes, optimized_mir, typeck")]
51 #[rustc_clean(cfg="cfail6")]
52 pub fn add_parameter() {
53     let x = 0u32;
54     let _ = |x: u32| x + 1;
55 }
56
57
58
59 // Change parameter pattern
60 #[cfg(any(cfail1,cfail4))]
61 pub fn change_parameter_pattern() {
62     let _ = | x  : (u32,)| x;
63 }
64
65 #[cfg(not(any(cfail1,cfail4)))]
66 #[rustc_clean(cfg="cfail2", except="hir_owner_nodes, typeck")]
67 #[rustc_clean(cfg="cfail3")]
68 #[rustc_clean(cfg="cfail5", except="hir_owner_nodes, typeck")]
69 #[rustc_clean(cfg="cfail6")]
70 pub fn change_parameter_pattern() {
71     let _ = |(x,): (u32,)| x;
72 }
73
74
75
76 // Add `move` to closure
77 #[cfg(any(cfail1,cfail4))]
78 pub fn add_move() {
79     let _ =      || 1;
80 }
81
82 #[cfg(not(any(cfail1,cfail4)))]
83 #[rustc_clean(cfg="cfail2", except="hir_owner_nodes")]
84 #[rustc_clean(cfg="cfail3")]
85 #[rustc_clean(cfg="cfail5", except="hir_owner_nodes")]
86 #[rustc_clean(cfg="cfail6")]
87 pub fn add_move() {
88     let _ = move || 1;
89 }
90
91
92
93 // Add type ascription to parameter
94 #[cfg(any(cfail1,cfail4))]
95 pub fn add_type_ascription_to_parameter() {
96     let closure = |x     | x + 1u32;
97     let _: u32 = closure(1);
98 }
99
100 #[cfg(not(any(cfail1,cfail4)))]
101 #[rustc_clean(cfg = "cfail2", except = "hir_owner_nodes, typeck")]
102 #[rustc_clean(cfg = "cfail3")]
103 #[rustc_clean(cfg = "cfail5", except = "hir_owner_nodes, typeck")]
104 #[rustc_clean(cfg = "cfail6")]
105 pub fn add_type_ascription_to_parameter() {
106     let closure = |x: u32| x + 1u32;
107     let _: u32 = closure(1);
108 }
109
110
111
112 // Change parameter type
113 #[cfg(any(cfail1,cfail4))]
114 pub fn change_parameter_type() {
115     let closure = |x: u32| (x as u64) + 1;
116     let _ = closure(1);
117 }
118
119 #[cfg(not(any(cfail1,cfail4)))]
120 #[rustc_clean(cfg="cfail2", except="hir_owner_nodes, optimized_mir, typeck")]
121 #[rustc_clean(cfg="cfail3")]
122 #[rustc_clean(cfg="cfail5", except="hir_owner_nodes, optimized_mir, typeck")]
123 #[rustc_clean(cfg="cfail6")]
124 pub fn change_parameter_type() {
125     let closure = |x: u16| (x as u64) + 1;
126     let _ = closure(1);
127 }