]> git.lizzy.rs Git - rust.git/blob - src/test/incremental/hashes/let_expressions.rs
reduce spans for `unsafe impl` errors
[rust.git] / src / test / incremental / hashes / let_expressions.rs
1 // This test case tests the incremental compilation hash (ICH) implementation
2 // for let expressions.
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 // Change Name -----------------------------------------------------------------
23 #[cfg(any(cfail1,cfail4))]
24 pub fn change_name() {
25     let _x = 2u64;
26 }
27
28 #[cfg(not(any(cfail1,cfail4)))]
29 #[rustc_clean(cfg="cfail2", except="hir_owner_nodes,optimized_mir")]
30 #[rustc_clean(cfg="cfail3")]
31 #[rustc_clean(cfg="cfail5", except="hir_owner_nodes,optimized_mir")]
32 #[rustc_clean(cfg="cfail6")]
33 pub fn change_name() {
34     let _y = 2u64;
35 }
36
37
38
39 // Add Type --------------------------------------------------------------------
40 #[cfg(any(cfail1,cfail4))]
41 pub fn add_type() {
42     let _x      = 2u32;
43 }
44
45 #[cfg(not(any(cfail1,cfail4)))]
46 #[rustc_clean(cfg="cfail2", except="hir_owner_nodes,typeck")]
47 #[rustc_clean(cfg="cfail3")]
48 #[rustc_clean(cfg="cfail5", except="hir_owner_nodes,typeck")]
49 #[rustc_clean(cfg="cfail6")]
50 pub fn add_type() {
51     let _x: u32 = 2u32;
52 }
53
54
55
56 // Change Type -----------------------------------------------------------------
57 #[cfg(any(cfail1,cfail4))]
58 pub fn change_type() {
59     let _x: u64 = 2;
60 }
61
62 #[cfg(not(any(cfail1,cfail4)))]
63 #[rustc_clean(cfg="cfail2", except="hir_owner_nodes,typeck,optimized_mir")]
64 #[rustc_clean(cfg="cfail3")]
65 #[rustc_clean(cfg="cfail5", except="hir_owner_nodes,typeck,optimized_mir")]
66 #[rustc_clean(cfg="cfail6")]
67 pub fn change_type() {
68     let _x: u8  = 2;
69 }
70
71
72
73 // Change Mutability of Reference Type -----------------------------------------
74 #[cfg(any(cfail1,cfail4))]
75 pub fn change_mutability_of_reference_type() {
76     let _x: &    u64;
77 }
78
79 #[cfg(not(any(cfail1,cfail4)))]
80 #[rustc_clean(cfg="cfail2", except="hir_owner_nodes,typeck,optimized_mir")]
81 #[rustc_clean(cfg="cfail3")]
82 #[rustc_clean(cfg="cfail5", except="hir_owner_nodes,typeck,optimized_mir")]
83 #[rustc_clean(cfg="cfail6")]
84 pub fn change_mutability_of_reference_type() {
85     let _x: &mut u64;
86 }
87
88
89
90 // Change Mutability of Slot ---------------------------------------------------
91 #[cfg(any(cfail1,cfail4))]
92 pub fn change_mutability_of_slot() {
93     let mut _x: u64 = 0;
94 }
95
96 #[cfg(not(any(cfail1,cfail4)))]
97 #[rustc_clean(cfg="cfail2", except="hir_owner_nodes,typeck,optimized_mir")]
98 #[rustc_clean(cfg="cfail3")]
99 #[rustc_clean(cfg="cfail5", except="hir_owner_nodes,typeck,optimized_mir")]
100 #[rustc_clean(cfg="cfail6")]
101 pub fn change_mutability_of_slot() {
102     let     _x: u64 = 0;
103 }
104
105
106
107 // Change Simple Binding to Pattern --------------------------------------------
108 #[cfg(any(cfail1,cfail4))]
109 pub fn change_simple_binding_to_pattern() {
110     let  _x      = (0u8, 'x');
111 }
112
113 #[cfg(not(any(cfail1,cfail4)))]
114 #[rustc_clean(cfg="cfail2", except="hir_owner_nodes,typeck,optimized_mir")]
115 #[rustc_clean(cfg="cfail3")]
116 #[rustc_clean(cfg="cfail5", except="hir_owner_nodes,typeck,optimized_mir")]
117 #[rustc_clean(cfg="cfail6")]
118 pub fn change_simple_binding_to_pattern() {
119     let (_a, _b) = (0u8, 'x');
120 }
121
122
123
124 // Change Name in Pattern ------------------------------------------------------
125 #[cfg(any(cfail1,cfail4))]
126 pub fn change_name_in_pattern() {
127     let (_a, _b) = (1u8, 'y');
128 }
129
130 #[cfg(not(any(cfail1,cfail4)))]
131 #[rustc_clean(cfg="cfail2", except="hir_owner_nodes,optimized_mir")]
132 #[rustc_clean(cfg="cfail3")]
133 #[rustc_clean(cfg="cfail5", except="hir_owner_nodes,optimized_mir")]
134 #[rustc_clean(cfg="cfail6")]
135 pub fn change_name_in_pattern() {
136     let (_a, _c) = (1u8, 'y');
137 }
138
139
140
141 // Add `ref` in Pattern --------------------------------------------------------
142 #[cfg(any(cfail1,cfail4))]
143 pub fn add_ref_in_pattern() {
144     let (    _a, _b) = (1u8, 'y');
145 }
146
147 #[cfg(not(any(cfail1,cfail4)))]
148 #[rustc_clean(cfg="cfail2", except="hir_owner_nodes,typeck,optimized_mir")]
149 #[rustc_clean(cfg="cfail3")]
150 #[rustc_clean(cfg="cfail5", except="hir_owner_nodes,typeck,optimized_mir")]
151 #[rustc_clean(cfg="cfail6")]
152 pub fn add_ref_in_pattern() {
153     let (ref _a, _b) = (1u8, 'y');
154 }
155
156
157
158 // Add `&` in Pattern ----------------------------------------------------------
159 #[cfg(any(cfail1,cfail4))]
160 pub fn add_amp_in_pattern() {
161     let ( _a, _b) = (&1u8, 'y');
162 }
163
164 #[cfg(not(any(cfail1,cfail4)))]
165 #[rustc_clean(cfg="cfail2", except="hir_owner_nodes,typeck,optimized_mir")]
166 #[rustc_clean(cfg="cfail3")]
167 #[rustc_clean(cfg="cfail5", except="hir_owner_nodes,typeck,optimized_mir")]
168 #[rustc_clean(cfg="cfail6")]
169 pub fn add_amp_in_pattern() {
170     let (&_a, _b) = (&1u8, 'y');
171 }
172
173
174
175 // Change Mutability of Binding in Pattern -------------------------------------
176 #[cfg(any(cfail1,cfail4))]
177 pub fn change_mutability_of_binding_in_pattern() {
178     let (    _a, _b) = (99u8, 'q');
179 }
180
181 #[cfg(not(any(cfail1,cfail4)))]
182 #[rustc_clean(cfg="cfail2", except="hir_owner_nodes,typeck,optimized_mir")]
183 #[rustc_clean(cfg="cfail3")]
184 #[rustc_clean(cfg="cfail5", except="hir_owner_nodes,typeck,optimized_mir")]
185 #[rustc_clean(cfg="cfail6")]
186 pub fn change_mutability_of_binding_in_pattern() {
187     let (mut _a, _b) = (99u8, 'q');
188 }
189
190
191
192 // Add Initializer -------------------------------------------------------------
193 #[cfg(any(cfail1,cfail4))]
194 pub fn add_initializer() {
195     let _x: i16       ;
196 }
197
198 #[cfg(not(any(cfail1,cfail4)))]
199 #[rustc_clean(cfg="cfail2", except="hir_owner_nodes,typeck,optimized_mir")]
200 #[rustc_clean(cfg="cfail3")]
201 #[rustc_clean(cfg="cfail5", except="hir_owner_nodes,typeck,optimized_mir")]
202 #[rustc_clean(cfg="cfail6")]
203 pub fn add_initializer() {
204     let _x: i16 = 3i16;
205 }
206
207
208
209 // Change Initializer ----------------------------------------------------------
210 #[cfg(any(cfail1,cfail4))]
211 pub fn change_initializer() {
212     let _x = 4u16;
213 }
214
215 #[cfg(not(any(cfail1,cfail4)))]
216 #[rustc_clean(cfg="cfail2", except="hir_owner_nodes")]
217 #[rustc_clean(cfg="cfail3")]
218 #[rustc_clean(cfg="cfail5", except="hir_owner_nodes")]
219 #[rustc_clean(cfg="cfail6")]
220 pub fn change_initializer() {
221     let _x = 5u16;
222 }