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
Copy file name to clipboardExpand all lines: src/doc/src/reference/semver.md
+6-5
Original file line number
Diff line number
Diff line change
@@ -213,22 +213,23 @@ crates should be avoided.
213
213
214
214
It is a breaking change to change the alignment, layout, or size of a type that was previously well-defined.
215
215
216
-
In general, nominal types that use the [the default representation] do not have a well-defined alignment, layout, or size.
216
+
In general, types that use the [the default representation] do not have a well-defined alignment, layout, or size.
217
217
The compiler is free to alter the alignment or layout, so code should not make any assumptions about it.
218
218
219
219
> **Note**: It may be possible for external crates to break if they make assumptions about the alignment, layout, or size of a type even if it is not well-defined.
220
220
> This is not considered a SemVer breaking change since those assumptions should not be made.
221
221
222
222
Some examples of changes that are not a breaking change are (assuming no other rules in this guide are violated):
223
223
224
-
* Adding, removing, or changing fields of a default representation struct, union, or enum.
225
-
* Adding variants to a default representation enum.
224
+
* Adding, removing, or changing fields of a default representation struct, union, or enum in such a way that the change follows the other rules in this guide (for example, using `non_exhaustive` to allow those changes, or changes to private fields that are already private).
225
+
* Adding variants to a default representation enum, if the enum uses `non_exhaustive`.
226
226
This may change the alignment or size of the enumeration, but those are not well-defined.
227
227
* Adding, removing, or changing private fields of a `repr(C)` struct, union, or enum.
228
228
Note that this may be a breaking change since it may change the size and alignment of the type.
229
229
Care should be taken in this case.
230
+
Adding private fields can only be done if there are already other private fields, or it is `non_exhaustive`.
230
231
Public fields may be added if there are private fields, or it is `non_exhaustive`, and the addition does not alter the layout of the other fields.
231
-
* Adding variants to a `repr(C)` enum.
232
+
* Adding variants to a `repr(C)` enum, if the enum uses `non_exhastive`.
232
233
Note that this may be a breaking change since it may change the size and alignment of the type.
233
234
Care should be taken in this case.
234
235
* Adding `repr(C)` to a default representation struct, union, or enum.
@@ -237,7 +238,7 @@ Some examples of changes that are not a breaking change are (assuming no other r
237
238
238
239
Nominal types that use the [`repr` attribute] can be said to have an alignment and layout that is defined in some way that code may make some assumptions about that may break as a result of changing that type.
239
240
240
-
Some examples of changes that are a breaking change are:
0 commit comments