Skip to content

Commit 7cc13f1

Browse files
authored
[cast] Fix safety comment bug for CastUnsized (#2908)
The decorated `unsafe impl` block is still sound, but the proof previously proved too much (namely, that the cast preserves referent size, when in fact it may shrink referent size). gherrit-pr-id: Gba34c175d9c27344e336de4ed088eb0754d87f30
1 parent 5c67d2c commit 7cc13f1

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

src/pointer/mod.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -139,9 +139,10 @@ pub mod cast {
139139
// - Both sized and equal in size
140140
// - Both slice DSTs with the same trailing slice offset and element size
141141
// and with align_of::<Src>() >= align_of::<Dst>(). These ensure that any
142-
// given pointer metadata encodes the same size for both `Src` and `Dst`
143-
// (note that the alignment is required as it affects the amount of
144-
// trailing padding).
142+
// given pointer metadata encodes the same size or more size for `Src`
143+
// than for `Dst` (note that the alignment is required as it affects the
144+
// amount of trailing padding). Thus, `project` preserves or shrinks the
145+
// set of referent bytes.
145146
unsafe impl<Src, Dst> Project<Src, Dst> for CastUnsized
146147
where
147148
Src: ?Sized + KnownLayout,

0 commit comments

Comments
 (0)