diff --git a/library/core/src/field.rs b/library/core/src/field.rs index e8ef309b9c84..0e537e2f92fc 100644 --- a/library/core/src/field.rs +++ b/library/core/src/field.rs @@ -8,7 +8,10 @@ #[expect(missing_debug_implementations)] #[fundamental] pub struct FieldRepresentingType { - _phantom: PhantomData, + // We want this type to be invariant over `T`, because otherwise `field_of!(Struct<'short>, + // field)` is a subtype of `field_of!(Struct<'long>, field)`. This subtype relationship does not + // have an immediately obvious meaning and we want to prevent people from relying on it. + _phantom: PhantomData T>, } // SAFETY: `FieldRepresentingType` doesn't contain any `T`