You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
#### Minor: `repr(C)` add, remove, or change a private field
278
+
#### Minor: `repr(C)` add, remove, or change a private field {#repr-c-private-change}
280
279
281
280
It is usually safe to add, remove, or change a private field of a `repr(C)` struct, union, or enum, assuming it follows the other guidelines in this guide (see [struct-add-private-field-when-public](#struct-add-private-field-when-public), [struct-add-public-field-when-no-private](#struct-add-public-field-when-no-private), [struct-private-fields-with-private](#struct-private-fields-with-private), [enum-fields-new](#enum-fields-new)).
It is usually safe to add variants to a `repr(C)` enum, if the enum uses `non_exhastive`.
325
323
See [enum-variant-new](#enum-variant-new) for more discussion.
@@ -359,8 +357,7 @@ fn main() {
359
357
}
360
358
```
361
359
362
-
<aid="repr-c-add"></a>
363
-
#### Minor: Adding `repr(C)` to a default representation
360
+
#### Minor: Adding `repr(C)` to a default representation {#repr-c-add}
364
361
365
362
It is safe to add `repr(C)` to a struct, union, or enum with [the default representation].
366
363
This is safe because users should not make assumptions about the alignment, layout, or size of types with with the default representation.
@@ -390,8 +387,7 @@ fn main() {
390
387
}
391
388
```
392
389
393
-
<aid="repr-int-enum-add"></a>
394
-
#### Minor: Adding `repr(<int>)` to an enum
390
+
#### Minor: Adding `repr(<int>)` to an enum {#repr-int-enum-add}
395
391
396
392
It is safe to add `repr(<int>)`[primitive representation] to an enum with [the default representation].
397
393
This is safe because users should not make assumptions about the alignment, layout, or size of an enum with the default representation.
@@ -423,8 +419,7 @@ fn main() {
423
419
}
424
420
```
425
421
426
-
<aid="repr-transparent-add"></a>
427
-
#### Minor: Adding `repr(transparent)` to a default representation struct or enum
422
+
#### Minor: Adding `repr(transparent)` to a default representation struct or enum {#repr-transparent-add}
428
423
429
424
It is safe to add `repr(transparent)` to a struct or enum with [the default representation].
430
425
This is safe because users should not make assumptions about the alignment, layout, or size of a struct or enum with the default representation.
@@ -450,8 +445,7 @@ fn main() {
450
445
}
451
446
```
452
447
453
-
<aid="repr-packed-add"></a>
454
-
#### Major: Adding `repr(packed)` to a struct or union
448
+
#### Major: Adding `repr(packed)` to a struct or union {#repr-packed-add}
455
449
456
450
It is a breaking change to add `repr(packed)` to a struct or union.
457
451
Making a type `repr(packed)` makes changes that can break code, such as being invalid to take a reference to a field, or causing truncation of disjoint closure captures.
@@ -510,8 +504,7 @@ fn main() {
510
504
}
511
505
```
512
506
513
-
<aid="repr-align-add"></a>
514
-
#### Major: Adding `repr(align)` to a struct, union, or enum
507
+
#### Major: Adding `repr(align)` to a struct, union, or enum {#repr-align-add}
515
508
516
509
It is a breaking change to add `repr(align)` to a struct, union, or enum.
517
510
Making a type `repr(align)` would break any use of that type in a `repr(packed)` type because that combination is not allowed.
@@ -550,8 +543,7 @@ fn main() {
550
543
}
551
544
```
552
545
553
-
<aid="repr-packed-remove"></a>
554
-
#### Major: Removing `repr(packed)` from a struct or union
546
+
#### Major: Removing `repr(packed)` from a struct or union {#repr-packed-remove}
555
547
556
548
It is a breaking change to remove `repr(packed)` from a struct or union.
557
549
This may change the alignment or layout that extern crates are relying on.
@@ -633,8 +625,7 @@ fn main() {
633
625
}
634
626
```
635
627
636
-
<aid="repr-packed-n-change"></a>
637
-
#### Major: Changing the value N of `repr(packed(N))` if that changes the alignment or layout
628
+
#### Major: Changing the value N of `repr(packed(N))` if that changes the alignment or layout {#repr-packed-n-change}
638
629
639
630
It is a breaking change to change the value of N of `repr(packed(N))` if that changes the alignment or layout.
640
631
This may change the alignment or layout that external crates are relying on.
@@ -672,8 +663,7 @@ fn main() {
672
663
}
673
664
```
674
665
675
-
<aid="repr-align-n-change"></a>
676
-
#### Major: Changing the value N of `repr(align(N))` if that changes the alignment
666
+
#### Major: Changing the value N of `repr(align(N))` if that changes the alignment {#repr-align-n-change}
677
667
678
668
It is a breaking change to change the value `N` of `repr(align(N))` if that changes the alignment.
679
669
This may change the alignment that external crates are relying on.
@@ -713,8 +703,7 @@ fn main() {
713
703
}
714
704
```
715
705
716
-
<aid="repr-align-remove"></a>
717
-
#### Major: Removing `repr(align)` from a struct, union, or enum
706
+
#### Major: Removing `repr(align)` from a struct, union, or enum {#repr-align-remove}
718
707
719
708
It is a breaking change to remove `repr(align)` from a struct, union, or enum, if their layout was well-defined.
720
709
This may change the alignment or layout that external crates are relying on.
@@ -752,8 +741,7 @@ fn main() {
752
741
}
753
742
```
754
743
755
-
<aid="repr-c-shuffle"></a>
756
-
#### Major: Changing the order of public fields of a `repr(C)` type
744
+
#### Major: Changing the order of public fields of a `repr(C)` type {#repr-c-shuffle}
757
745
758
746
It is a breaking change to change the order of public fields of a `repr(C)` type.
759
747
External crates may be relying on the specific ordering of the fields.
@@ -807,8 +795,7 @@ fn main() {
807
795
# }
808
796
```
809
797
810
-
<aid="repr-c-remove"></a>
811
-
#### Major: Removing `repr(C)` from a struct, union, or enum
798
+
#### Major: Removing `repr(C)` from a struct, union, or enum {#repr-c-remove}
812
799
813
800
It is a breaking change to remove `repr(C)` from a struct, union, or enum.
814
801
External crates may be relying on the specific layout of the type.
@@ -862,8 +849,7 @@ fn main() {
862
849
# }
863
850
```
864
851
865
-
<aid="repr-int-enum-remove"></a>
866
-
#### Major: Removing `repr(<int>)` from an enum
852
+
#### Major: Removing `repr(<int>)` from an enum {#repr-int-enum-remove}
867
853
868
854
It is a breaking change to remove `repr(<int>)` from an enum.
869
855
External crates may be assuming that the discriminant is a specific size.
@@ -899,8 +885,7 @@ fn main() {
899
885
}
900
886
```
901
887
902
-
<aid="repr-int-enum-change"></a>
903
-
#### Major: Changing the primitive representation of a `repr(<int>)` enum
888
+
#### Major: Changing the primitive representation of a `repr(<int>)` enum {#repr-int-enum-change}
904
889
905
890
It is a breaking change to change the primitive representation of a `repr(<int>)` enum.
906
891
External crates may be assuming that the discriminant is a specific size.
@@ -936,8 +921,7 @@ fn main() {
936
921
}
937
922
```
938
923
939
-
<aid="repr-transparent-remove"></a>
940
-
#### Major: Removing `repr(transparent)` from a struct or enum
924
+
#### Major: Removing `repr(transparent)` from a struct or enum {#repr-transparent-remove}
941
925
942
926
It is a breaking change to remove `repr(transparent)` from a struct or enum.
943
927
External crates may be relying on the type having the alignment, layout, or size of the transparent field.
0 commit comments