Skip to content

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

@arielb1

Description

@arielb1

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-borrow-checkerArea: The borrow checkerA-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