Skip to content

MaybeUninit requires T: Sized but it should not #80158

Open
@mahkoh

Description

@mahkoh

I tried this code:

pub fn as_maybe_uninit<T: ?Sized>(t: &T) -> &MaybeUninit<T> {
    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-raw-pointersArea: raw pointers, MaybeUninit, NonNullT-langRelevant to the language team, which will review and decide on the PR/issue.T-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions