@@ -341,11 +341,19 @@ proposal (and -- further -- it does not match our existing behavior):
341
341
ahead of
342
342
time] ( https://github.com/rust-rfcs/unsafe-code-guidelines/issues/11#issuecomment-420659840 ) ,
343
343
so the user cannot do it manually.
344
- - If layout is defined, then it becomes part of your API, such taht
345
- reordering fields is a breaking change for your clients (if we
346
- consider unsafe code that may rely on the layout, then this applies
347
- [ even to structs with named
348
- fields] ( https://github.com/rust-rfcs/unsafe-code-guidelines/issues/11#issuecomment-420117856 ) .
344
+ - If layout is defined, and a library exposes a struct with all public
345
+ fields, then clients may be more likely to assume that the layout of
346
+ that struct is stable. If they were to write unsafe code that relied
347
+ on this assumption, that would break if fields were reordered. But
348
+ libraries may well expect the freedom to reorder fields. This case
349
+ is weakened because of the requirement to write unsafe code (after
350
+ all, one can always write unsafe code that relies on virtually any
351
+ implementation detail); if we were to permit ** safe** casts that
352
+ rely on the layout, then reordering fields would clearly be a
353
+ breaking change (see also [ this
354
+ comment] ( https://github.com/rust-rfcs/unsafe-code-guidelines/issues/11#issuecomment-420117856 )
355
+ and [ this
356
+ thread] ( https://github.com/rust-rfcs/unsafe-code-guidelines/pull/31#discussion_r224955817 ) ).
349
357
- Many people would prefer the name ordering to be chosen for
350
358
"readability" and not optimal layout.
351
359
0 commit comments