Commit 9c88f3b
committed
Auto merge of #24765 - pnkfelix:fsk-enum-swapindrop, r=nikomatsakis
Inspect enum discriminant *after* calling its destructor
Includes some drive-by cleanup (e.g. changed some field and method names to reflect fill-on-drop; added comments about zero-variant enums being classified as `_match::Single`).
Probably the most invasive change was the expansion of the maps `available_drop_glues` and `drop_glues` to now hold two different kinds of drop glues; there is the (old) normal drop glue, and there is (new) drop-contents glue that jumps straight to dropping the contents of a struct or enum, skipping its destructor.
* For all types that do not have user-defined Drop implementations, the normal glue is generated as usual (i.e. recursively dropping the fields of the data structure).
(And this actually is exactly what the newly-added drop-contents glue does as well.)
* For types that have user-defined Drop implementations, the "normal" drop glue now schedules a cleanup before invoking the `Drop::drop` method that will call the drop-contents glue after that invocation returns.
Fix #23611.
----
Is this a breaking change? The prior behavior was totally unsound, and it seems unreasonable that anyone was actually relying on it.
Nonetheless, since there is a user-visible change to the language semantics, I guess I will conservatively mark this as a:
[breaking-change]
(To see an example of what sort of user-visible change this causes, see the comments in the regression test.)File tree
7 files changed
+447
-116
lines changed- src
- librustc_trans/trans
- test/run-pass
7 files changed
+447
-116
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
916 | 916 | | |
917 | 917 | | |
918 | 918 | | |
919 | | - | |
920 | 919 | | |
| 920 | + | |
921 | 921 | | |
922 | 922 | | |
923 | 923 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
771 | 771 | | |
772 | 772 | | |
773 | 773 | | |
| 774 | + | |
774 | 775 | | |
775 | 776 | | |
776 | 777 | | |
| |||
1062 | 1063 | | |
1063 | 1064 | | |
1064 | 1065 | | |
1065 | | - | |
| 1066 | + | |
1066 | 1067 | | |
1067 | 1068 | | |
1068 | 1069 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
471 | 471 | | |
472 | 472 | | |
473 | 473 | | |
474 | | - | |
475 | | - | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
476 | 479 | | |
477 | 480 | | |
478 | 481 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
393 | 393 | | |
394 | 394 | | |
395 | 395 | | |
396 | | - | |
| 396 | + | |
| 397 | + | |
397 | 398 | | |
398 | 399 | | |
399 | | - | |
| 400 | + | |
400 | 401 | | |
401 | 402 | | |
402 | | - | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
403 | 406 | | |
404 | 407 | | |
405 | 408 | | |
406 | 409 | | |
407 | | - | |
408 | | - | |
| 410 | + | |
| 411 | + | |
409 | 412 | | |
410 | 413 | | |
411 | 414 | | |
| |||
416 | 419 | | |
417 | 420 | | |
418 | 421 | | |
419 | | - | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
420 | 456 | | |
421 | 457 | | |
422 | | - | |
| 458 | + | |
423 | 459 | | |
424 | 460 | | |
425 | 461 | | |
426 | | - | |
| 462 | + | |
| 463 | + | |
427 | 464 | | |
428 | 465 | | |
429 | 466 | | |
| |||
440 | 477 | | |
441 | 478 | | |
442 | 479 | | |
443 | | - | |
| 480 | + | |
| 481 | + | |
444 | 482 | | |
445 | 483 | | |
446 | | - | |
| 484 | + | |
447 | 485 | | |
448 | 486 | | |
449 | | - | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
450 | 490 | | |
451 | 491 | | |
452 | 492 | | |
| |||
987 | 1027 | | |
988 | 1028 | | |
989 | 1029 | | |
990 | | - | |
| 1030 | + | |
| 1031 | + | |
991 | 1032 | | |
992 | 1033 | | |
993 | 1034 | | |
| |||
1007 | 1048 | | |
1008 | 1049 | | |
1009 | 1050 | | |
1010 | | - | |
| 1051 | + | |
| 1052 | + | |
| 1053 | + | |
| 1054 | + | |
| 1055 | + | |
| 1056 | + | |
1011 | 1057 | | |
1012 | | - | |
| 1058 | + | |
1013 | 1059 | | |
1014 | | - | |
| 1060 | + | |
1015 | 1061 | | |
1016 | | - | |
| 1062 | + | |
1017 | 1063 | | |
1018 | 1064 | | |
1019 | 1065 | | |
| |||
1190 | 1236 | | |
1191 | 1237 | | |
1192 | 1238 | | |
1193 | | - | |
| 1239 | + | |
1194 | 1240 | | |
1195 | 1241 | | |
1196 | 1242 | | |
| 1243 | + | |
| 1244 | + | |
| 1245 | + | |
| 1246 | + | |
1197 | 1247 | | |
1198 | 1248 | | |
1199 | 1249 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
| 24 | + | |
24 | 25 | | |
25 | 26 | | |
26 | 27 | | |
| |||
73 | 74 | | |
74 | 75 | | |
75 | 76 | | |
76 | | - | |
| 77 | + | |
77 | 78 | | |
78 | 79 | | |
79 | 80 | | |
| |||
89 | 90 | | |
90 | 91 | | |
91 | 92 | | |
92 | | - | |
| 93 | + | |
93 | 94 | | |
94 | 95 | | |
95 | 96 | | |
| |||
574 | 575 | | |
575 | 576 | | |
576 | 577 | | |
577 | | - | |
| 578 | + | |
578 | 579 | | |
579 | 580 | | |
580 | 581 | | |
| |||
660 | 661 | | |
661 | 662 | | |
662 | 663 | | |
663 | | - | |
| 664 | + | |
664 | 665 | | |
665 | 666 | | |
666 | 667 | | |
| |||
0 commit comments