Auto merge of #54703 - davidtwco:issue-52086, r=nikomatsakis

error message when trying to move from an Rc or Arc is ungreat

Fixes #52086.

r? @nikomatsakis
This commit is contained in:
bors 2018-10-05 07:40:36 +00:00
commit 61f5ca7d64
13 changed files with 216 additions and 12 deletions

View file

@ -0,0 +1,9 @@
error[E0507]: cannot move out of an `Rc`
--> $DIR/borrowck-move-out-of-overloaded-auto-deref.rs:17:14
|
LL | let _x = Rc::new(vec![1, 2]).into_iter();
| ^^^^^^^^^^^^^^^^^^^ cannot move out of an `Rc`
error: aborting due to previous error
For more information about this error, try `rustc --explain E0507`.

View file

@ -1,8 +1,8 @@
error[E0507]: cannot move out of borrowed content
error[E0507]: cannot move out of an `Rc`
--> $DIR/borrowck-move-out-of-overloaded-auto-deref.rs:17:14
|
LL | let _x = Rc::new(vec![1, 2]).into_iter();
| ^^^^^^^^^^^^^^^^^^^ cannot move out of borrowed content
| ^^^^^^^^^^^^^^^^^^^ cannot move out of an `Rc`
error: aborting due to previous error

View file

@ -1,10 +1,10 @@
error[E0507]: cannot move out of borrowed content
error[E0507]: cannot move out of an `Rc`
--> $DIR/borrowck-move-out-of-overloaded-deref.rs:14:14
|
LL | let _x = *Rc::new("hi".to_string());
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
| |
| cannot move out of borrowed content
| cannot move out of an `Rc`
| help: consider removing the `*`: `Rc::new("hi".to_string())`
error: aborting due to previous error

View file

@ -0,0 +1,24 @@
// Copyright 2017 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)]
use std::rc::Rc;
use std::sync::Arc;
struct Bar { field: Vec<i32> }
fn main() {
let x = Rc::new(Bar { field: vec![] });
drop(x.field);
let y = Arc::new(Bar { field: vec![] });
drop(y.field);
}

View file

@ -0,0 +1,15 @@
error[E0507]: cannot move out of an `Rc`
--> $DIR/issue-52086.rs:20:10
|
LL | drop(x.field);
| ^^^^^^^ cannot move out of an `Rc`
error[E0507]: cannot move out of an `Arc`
--> $DIR/issue-52086.rs:23:10
|
LL | drop(y.field);
| ^^^^^^^ cannot move out of an `Arc`
error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0507`.

View file

@ -25,13 +25,13 @@ LL | let s = **r;
| cannot move out of borrowed content
| help: consider removing the `*`: `*r`
error[E0507]: cannot move out of borrowed content
error[E0507]: cannot move out of an `Rc`
--> $DIR/move-errors.rs:40:13
|
LL | let s = *r;
| ^^
| |
| cannot move out of borrowed content
| cannot move out of an `Rc`
| help: consider removing the `*`: `r`
error[E0508]: cannot move out of type `[A; 1]`, a non-copy array