File tree Expand file tree Collapse file tree 2 files changed +39
-0
lines changed Expand file tree Collapse file tree 2 files changed +39
-0
lines changed Original file line number Diff line number Diff line change 1+ // Copyright 2015 The Rust Project Developers. See the COPYRIGHT
2+ // file at the top-level directory of this distribution and at
3+ // http://rust-lang.org/COPYRIGHT.
4+ //
5+ // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+ // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+ // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+ // option. This file may not be copied, modified, or distributed
9+ // except according to those terms.
10+
11+ // compile-flags: -Z borrowck-mir -Z emit-end-regions
12+
13+ fn main ( ) {
14+ let mut x = Box :: new ( 0 ) ;
15+ let _u = x; // error shouldn't note this move
16+ x = Box :: new ( 1 ) ;
17+ drop ( x) ;
18+ let _ = ( 1 , x) ;
19+ }
Original file line number Diff line number Diff line change 1+ error[E0382]: use of moved value: `x` (Ast)
2+ --> $DIR/borrowck-reinit.rs:18:16
3+ |
4+ 17 | drop(x);
5+ | - value moved here
6+ 18 | let _ = (1,x);
7+ | ^ value used here after move
8+ |
9+ = note: move occurs because `x` has type `std::boxed::Box<i32>`, which does not implement the `Copy` trait
10+
11+ error[E0382]: use of moved value: `x` (Mir)
12+ --> $DIR/borrowck-reinit.rs:18:16
13+ |
14+ 17 | drop(x);
15+ | - value moved here
16+ 18 | let _ = (1,x);
17+ | ^ value use here after move
18+
19+ error: aborting due to 2 previous errors
20+
You can’t perform that action at this time.
0 commit comments