Skip to content

MIR borrowck: no "move occurs because X is not Copy` error #46631

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
arielb1 opened this issue Dec 10, 2017 · 1 comment
Closed

MIR borrowck: no "move occurs because X is not Copy` error #46631

arielb1 opened this issue Dec 10, 2017 · 1 comment
Labels
A-borrow-checker Area: The borrow checker A-diagnostics Area: Messages for errors, warnings, and lints T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@arielb1
Copy link
Contributor

arielb1 commented Dec 10, 2017

e.g. in the test moves-based-on-type-tuple:

#![feature(box_syntax)]

fn dup(x: Box<isize>) -> Box<(Box<isize>,Box<isize>)> {
    box (x, x) //~ ERROR use of moved value
}
fn main() {
    dup(box 3);
}

In the "use of moved value" error, AST borrowck reports the type of the moved value, while MIR borrowck doesn't:

error[E0382]: use of moved value: `x` (Ast)
  --> /home/ariel/Rust/rust-master/src/test/compile-fail/moves-based-on-type-tuple.rs:14:13
   |
14 |     box (x, x) //~ ERROR use of moved value
   |          -  ^ value used here after move
   |          |
   |          value moved here
   |
   = note: move occurs because `x` has type `std::boxed::Box<isize>`, which does not implement the `Copy` trait
         COMMENT MINE: \----- it would be nice if MIR borrowck would report this too

error[E0382]: use of moved value: `x` (Mir)
  --> /home/ariel/Rust/rust-master/src/test/compile-fail/moves-based-on-type-tuple.rs:14:13
   |
14 |     box (x, x) //~ ERROR use of moved value
   |          -  ^ value used here after move
   |          |
   |          value moved here

error: aborting due to 2 previous errors

@arielb1 arielb1 added A-borrow-checker Area: The borrow checker A-diagnostics Area: Messages for errors, warnings, and lints WG-compiler-nll labels Dec 10, 2017
@davidtwco
Copy link
Member

I'll take a look at this one.

@pnkfelix pnkfelix added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Dec 21, 2017
bors added a commit that referenced this issue Dec 25, 2017
MIR borrowck: no "move occurs because `X` is not Copy` error

Fixes #46631.

r? @arielb1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-borrow-checker Area: The borrow checker A-diagnostics Area: Messages for errors, warnings, and lints 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

3 participants