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:
commit
61f5ca7d64
13 changed files with 216 additions and 12 deletions
|
|
@ -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`.
|
||||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
24
src/test/ui/nll/issue-52086.rs
Normal file
24
src/test/ui/nll/issue-52086.rs
Normal 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);
|
||||
}
|
||||
15
src/test/ui/nll/issue-52086.stderr
Normal file
15
src/test/ui/nll/issue-52086.stderr
Normal 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`.
|
||||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue