Commit 0f04df8
committed
auto merge of #4866 : jld/rust/enum-unitlike, r=graydon
If an enum is isomorphic to unit, there's no need to use any bits to
represent it. The only obvious reason this wasn't the case was because
the enum could be C-like and have a user-specified discriminant -- but
that value is constant, so it doesn't need to be stored.
This change means that all newtype-like enums have the same size (and
layout) as their underlying type, which might be a useful property to
have, at least in terms of making programs' low-level behavior less
surprising.3 files changed
+29
-14
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
407 | 407 | | |
408 | 408 | | |
409 | 409 | | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
410 | 414 | | |
411 | 415 | | |
412 | 416 | | |
| |||
418 | 422 | | |
419 | 423 | | |
420 | 424 | | |
| 425 | + | |
421 | 426 | | |
422 | 427 | | |
423 | 428 | | |
| |||
442 | 447 | | |
443 | 448 | | |
444 | 449 | | |
445 | | - | |
| 450 | + | |
446 | 451 | | |
447 | 452 | | |
448 | 453 | | |
449 | 454 | | |
450 | 455 | | |
451 | 456 | | |
452 | | - | |
| 457 | + | |
453 | 458 | | |
454 | 459 | | |
455 | 460 | | |
| |||
464 | 469 | | |
465 | 470 | | |
466 | 471 | | |
467 | | - | |
468 | | - | |
469 | 472 | | |
470 | 473 | | |
471 | 474 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
674 | 674 | | |
675 | 675 | | |
676 | 676 | | |
677 | | - | |
| 677 | + | |
678 | 678 | | |
679 | 679 | | |
680 | 680 | | |
681 | 681 | | |
682 | 682 | | |
| 683 | + | |
| 684 | + | |
| 685 | + | |
683 | 686 | | |
684 | 687 | | |
685 | 688 | | |
| |||
1591 | 1594 | | |
1592 | 1595 | | |
1593 | 1596 | | |
1594 | | - | |
1595 | | - | |
1596 | | - | |
1597 | | - | |
| 1597 | + | |
| 1598 | + | |
| 1599 | + | |
| 1600 | + | |
| 1601 | + | |
| 1602 | + | |
| 1603 | + | |
| 1604 | + | |
| 1605 | + | |
| 1606 | + | |
| 1607 | + | |
| 1608 | + | |
| 1609 | + | |
| 1610 | + | |
| 1611 | + | |
| 1612 | + | |
1598 | 1613 | | |
1599 | 1614 | | |
1600 | 1615 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
242 | 242 | | |
243 | 243 | | |
244 | 244 | | |
245 | | - | |
| 245 | + | |
246 | 246 | | |
247 | | - | |
| 247 | + | |
248 | 248 | | |
249 | 249 | | |
250 | | - | |
251 | | - | |
252 | | - | |
253 | 250 | | |
254 | 251 | | |
255 | 252 | | |
| |||
0 commit comments