diff --git a/src/polyfill/uninit_slice.rs b/src/polyfill/uninit_slice.rs index be921c23a5..a23359760b 100644 --- a/src/polyfill/uninit_slice.rs +++ b/src/polyfill/uninit_slice.rs @@ -201,7 +201,14 @@ impl<'target, E> From<&'target mut [MaybeUninit]> for Uninit<'target, E> { // A pointer to an `Uninit` that remembers the `Uninit`'s lifetime. pub struct AliasedUninit<'target, E> { target: *mut [MaybeUninit], - _a: PhantomData<&'target mut [MaybeUninit]>, + // `()` is a zero-sized type, whereas `[MaybeUninit]` isn't. From + // https://rust-lang.github.io/unsafe-code-guidelines/glossary.html#aliasing, + // "One interesting side effect of these rules is that references and + // pointers to Zero Sized Types never alias each other, because their span + // length is always 0 bytes." So this allows us to mention `'target` + // basically without any other effect, or even alluding to any other + // effect. + _a: PhantomData<&'target mut ()>, } impl StartPtr for &AliasedUninit<'_, E> {