Inspect parents paths when checking for moves
This commit is contained in:
parent
f1aefb48d2
commit
e9029cec7b
6 changed files with 97 additions and 1 deletions
28
src/test/ui/nll/issue-52669.rs
Normal file
28
src/test/ui/nll/issue-52669.rs
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
#![feature(nll)]
|
||||
|
||||
struct A {
|
||||
b: B,
|
||||
}
|
||||
|
||||
#[derive(Clone)]
|
||||
struct B;
|
||||
|
||||
fn foo(_: A) {}
|
||||
|
||||
fn bar(mut a: A) -> B {
|
||||
a.b = B;
|
||||
foo(a);
|
||||
a.b.clone()
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
13
src/test/ui/nll/issue-52669.stderr
Normal file
13
src/test/ui/nll/issue-52669.stderr
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
error[E0382]: borrow of moved value: `a.b`
|
||||
--> $DIR/issue-52669.rs:25:5
|
||||
|
|
||||
LL | foo(a);
|
||||
| - value moved here
|
||||
LL | a.b.clone()
|
||||
| ^^^ value borrowed here after move
|
||||
|
|
||||
= note: move occurs because `a` has type `A`, which does not implement the `Copy` trait
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0382`.
|
||||
17
src/test/ui/nll/move-subpaths-moves-root.rs
Normal file
17
src/test/ui/nll/move-subpaths-moves-root.rs
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
#![feature(nll)]
|
||||
|
||||
fn main() {
|
||||
let x = (vec![1, 2, 3], );
|
||||
drop(x.0);
|
||||
drop(x);
|
||||
}
|
||||
13
src/test/ui/nll/move-subpaths-moves-root.stderr
Normal file
13
src/test/ui/nll/move-subpaths-moves-root.stderr
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
error[E0382]: use of moved value: `x`
|
||||
--> $DIR/move-subpaths-moves-root.rs:16:10
|
||||
|
|
||||
LL | drop(x.0);
|
||||
| --- value moved here
|
||||
LL | drop(x);
|
||||
| ^ value used here after move
|
||||
|
|
||||
= note: move occurs because `x.0` has type `std::vec::Vec<i32>`, which does not implement the `Copy` trait
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0382`.
|
||||
Loading…
Add table
Add a link
Reference in a new issue