MaybeUninit requires T: Sized but it should not (original) (raw)

I tried this code:

pub fn as_maybe_uninit<T: ?Sized>(t: &T) -> &MaybeUninit { unsafe { mem::transmute(t) } }

I expected to see this happen: It compiles

Instead, this happened: It does not compile

Meta

rustc --version --verbose:

rustc 1.48.0 (7eac88abb 2020-11-16)
binary: rustc
commit-hash: 7eac88abb2e57e752f3302f02be5f3ce3d7adfb4
commit-date: 2020-11-16
host: x86_64-unknown-linux-gnu
release: 1.48.0
LLVM version: 11.0