Skip to content

Goofy error when destructuring via Box pattern #38700

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
pnkfelix opened this issue Dec 30, 2016 · 3 comments
Closed

Goofy error when destructuring via Box pattern #38700

pnkfelix opened this issue Dec 30, 2016 · 3 comments
Labels
P-medium Medium priority T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@pnkfelix
Copy link
Member

Consider this code:

fn main() {
    use std::boxed;
    let boxed::Box(..) = boxed::Box::new("Hello");
}

on the playpen, it yields the error:

rustc 1.16.0-nightly (4ecc85beb 2016-12-28)
error[E0308]: mismatched types
 --> <anon>:3:9
  |
3 |     let boxed::Box(..) = boxed::Box::new("Hello");
  |         ^^^^^^^^^^^^^^ expected box, found struct `std::boxed::Box`
  |
  = note: expected type `Box<&str>`
  = note:    found type `std::boxed::Box<_>`

error: aborting due to previous error

This is probably an artifact of how we partially treat Boxes as a built-in language feature within the compiler. Nonetheless, we could do better with the message here.

@pnkfelix pnkfelix added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Dec 30, 2016
@pnkfelix
Copy link
Member Author

triage: P-medium

@rust-highfive rust-highfive added the P-medium Medium priority label Dec 30, 2016
@pnkfelix
Copy link
Member Author

(I don't regard this as terribly important to fix, at least not on its own. And of course in general we are planning to move towards a world where Box is not built-in, but doing so requires something like `DerefMove.)

@pnkfelix
Copy link
Member Author

Oh wait, this is a dupe of #22207

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P-medium Medium priority T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

2 participants