Skip to content

Commit 1f5eea2

Browse files
authored
[projection] Clarify comment explaining fallibility (#2939)
gherrit-pr-id: G11dfbd515f9e3a58b6e66367f787a5d5debe31bf
1 parent 4f2643c commit 1f5eea2

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

src/lib.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1224,11 +1224,13 @@ where
12241224
_enum_variant => {
12251225
use crate::invariant::{Validity, ValidityKind};
12261226
match I::Validity::KIND {
1227-
// The projectability of a field from an `Uninit` or
1228-
// `Initialized` union cannot generally depend on
1229-
// the referent's value, because the union's
1230-
// discriminant is not in a valid state, and thus
1231-
// cannot be used to discriminate between variants.
1227+
// The `Uninit` and `Initialized` validity
1228+
// invariants do not depend on the enum's tag. In
1229+
// particular, we don't actually care about what
1230+
// variant is present – we can treat *any* range of
1231+
// uninitialized or initialized memory as containing
1232+
// an uninitialized or initialized instance of *any*
1233+
// type – the type itself is irrelevant.
12321234
ValidityKind::Uninit | ValidityKind::Initialized => true,
12331235
// The projectability of an enum field from an
12341236
// `AsInitialized` or `Valid` state is a dynamic

0 commit comments

Comments
 (0)