Skip to content

Matching Box(<pattern>) against Box<T> should give privacy error, not type mismatch #22207

Closed
@shepmaster

Description

@shepmaster

While looking at #22205, I tried this as a workaround:

struct NonCopy;

fn main() {
    let x = Box::new(NonCopy);
    let Box(y) = x;
}

However, this has the error:

<anon>:5:9: 5:15 error: mismatched types:
 expected `Box<NonCopy>`,
    found `alloc::boxed::Box<_>`
(expected box,
    found struct `alloc::boxed::Box`) [E0308]
<anon>:5     let Box(y) = x;
                 ^~~~~~

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsT-compilerRelevant to the compiler 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