Commit d4f23cd
authored
Rollup merge of rust-lang#142570 - jieyouxu:disunion, r=estebank
Reject union default field values
Fixes rust-lang#142555.
The [`default_field_values` RFC][rfc] does not specify that default field values may be used on `union`s, and it's not clear how default field values may be used with `union`s without an design extension to the RFC. So, for now, reject trying to use default field values with `union`s.
### Review notes
- The first commit adds the `union` with default field values test case to `tests/ui/structs/default-field-values/failures.rs`, where `union`s with default field values are currently accepted.
- The second commit rejects trying to supply default field values to `union` definitions.
- When `default_field_values` feature gate is disabled, we show the feature gate error when the user tries to write `union`s with default field values. When the feature gate is enabled, we reject this usage with
> unions cannot have default field values
``@rustbot`` label: +F-default_field_values
[rfc]: https://rust-lang.github.io/rfcs/3681-default-field-values.htmlFile tree
7 files changed
+115
-36
lines changed- compiler/rustc_ast_lowering
- src
- tests/ui
- feature-gates
- structs/default-field-values
7 files changed
+115
-36
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
179 | 179 | | |
180 | 180 | | |
181 | 181 | | |
| 182 | + | |
| 183 | + | |
182 | 184 | | |
183 | 185 | | |
184 | 186 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
475 | 475 | | |
476 | 476 | | |
477 | 477 | | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
| 20 | + | |
20 | 21 | | |
21 | 22 | | |
22 | 23 | | |
| |||
316 | 317 | | |
317 | 318 | | |
318 | 319 | | |
319 | | - | |
| 320 | + | |
320 | 321 | | |
321 | 322 | | |
322 | 323 | | |
| |||
328 | 329 | | |
329 | 330 | | |
330 | 331 | | |
331 | | - | |
| 332 | + | |
332 | 333 | | |
333 | 334 | | |
334 | 335 | | |
| |||
338 | 339 | | |
339 | 340 | | |
340 | 341 | | |
341 | | - | |
| 342 | + | |
342 | 343 | | |
343 | 344 | | |
344 | 345 | | |
| |||
714 | 715 | | |
715 | 716 | | |
716 | 717 | | |
717 | | - | |
| 718 | + | |
718 | 719 | | |
719 | 720 | | |
720 | 721 | | |
721 | 722 | | |
722 | 723 | | |
723 | | - | |
| 724 | + | |
724 | 725 | | |
725 | 726 | | |
726 | 727 | | |
| |||
730 | 731 | | |
731 | 732 | | |
732 | 733 | | |
| 734 | + | |
733 | 735 | | |
734 | 736 | | |
735 | 737 | | |
736 | | - | |
737 | | - | |
| 738 | + | |
| 739 | + | |
738 | 740 | | |
739 | | - | |
740 | | - | |
741 | | - | |
| 741 | + | |
| 742 | + | |
| 743 | + | |
| 744 | + | |
| 745 | + | |
| 746 | + | |
| 747 | + | |
| 748 | + | |
| 749 | + | |
| 750 | + | |
| 751 | + | |
| 752 | + | |
| 753 | + | |
| 754 | + | |
| 755 | + | |
| 756 | + | |
| 757 | + | |
| 758 | + | |
| 759 | + | |
| 760 | + | |
| 761 | + | |
| 762 | + | |
| 763 | + | |
742 | 764 | | |
743 | 765 | | |
744 | 766 | | |
| |||
Lines changed: 10 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
58 | 58 | | |
59 | 59 | | |
60 | 60 | | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
61 | 71 | | |
62 | 72 | | |
63 | 73 | | |
| |||
Lines changed: 37 additions & 17 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
124 | 124 | | |
125 | 125 | | |
126 | 126 | | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
127 | 147 | | |
128 | | - | |
| 148 | + | |
129 | 149 | | |
130 | 150 | | |
131 | 151 | | |
| |||
140 | 160 | | |
141 | 161 | | |
142 | 162 | | |
143 | | - | |
| 163 | + | |
144 | 164 | | |
145 | 165 | | |
146 | 166 | | |
| |||
155 | 175 | | |
156 | 176 | | |
157 | 177 | | |
158 | | - | |
| 178 | + | |
159 | 179 | | |
160 | 180 | | |
161 | 181 | | |
| |||
170 | 190 | | |
171 | 191 | | |
172 | 192 | | |
173 | | - | |
| 193 | + | |
174 | 194 | | |
175 | 195 | | |
176 | 196 | | |
| |||
185 | 205 | | |
186 | 206 | | |
187 | 207 | | |
188 | | - | |
| 208 | + | |
189 | 209 | | |
190 | 210 | | |
191 | 211 | | |
| |||
200 | 220 | | |
201 | 221 | | |
202 | 222 | | |
203 | | - | |
| 223 | + | |
204 | 224 | | |
205 | 225 | | |
206 | 226 | | |
| |||
215 | 235 | | |
216 | 236 | | |
217 | 237 | | |
218 | | - | |
| 238 | + | |
219 | 239 | | |
220 | 240 | | |
221 | 241 | | |
| |||
230 | 250 | | |
231 | 251 | | |
232 | 252 | | |
233 | | - | |
| 253 | + | |
234 | 254 | | |
235 | 255 | | |
236 | 256 | | |
| |||
245 | 265 | | |
246 | 266 | | |
247 | 267 | | |
248 | | - | |
| 268 | + | |
249 | 269 | | |
250 | 270 | | |
251 | 271 | | |
| |||
256 | 276 | | |
257 | 277 | | |
258 | 278 | | |
259 | | - | |
| 279 | + | |
260 | 280 | | |
261 | 281 | | |
262 | 282 | | |
| |||
267 | 287 | | |
268 | 288 | | |
269 | 289 | | |
270 | | - | |
| 290 | + | |
271 | 291 | | |
272 | 292 | | |
273 | 293 | | |
| |||
279 | 299 | | |
280 | 300 | | |
281 | 301 | | |
282 | | - | |
| 302 | + | |
283 | 303 | | |
284 | 304 | | |
285 | 305 | | |
| |||
294 | 314 | | |
295 | 315 | | |
296 | 316 | | |
297 | | - | |
| 317 | + | |
298 | 318 | | |
299 | 319 | | |
300 | 320 | | |
| |||
309 | 329 | | |
310 | 330 | | |
311 | 331 | | |
312 | | - | |
| 332 | + | |
313 | 333 | | |
314 | 334 | | |
315 | 335 | | |
| |||
320 | 340 | | |
321 | 341 | | |
322 | 342 | | |
323 | | - | |
| 343 | + | |
324 | 344 | | |
325 | 345 | | |
326 | 346 | | |
| |||
331 | 351 | | |
332 | 352 | | |
333 | 353 | | |
334 | | - | |
| 354 | + | |
335 | 355 | | |
336 | 356 | | |
337 | 357 | | |
| |||
342 | 362 | | |
343 | 363 | | |
344 | 364 | | |
345 | | - | |
| 365 | + | |
346 | 366 | | |
347 | 367 | | |
348 | 368 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
49 | 49 | | |
50 | 50 | | |
51 | 51 | | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
52 | 58 | | |
53 | 59 | | |
54 | 60 | | |
| |||
0 commit comments