Closed
Description
This example
use std::rc::Rc;
struct Bar { field: Vec<i32> }
fn main() {
let x = Rc::new(Bar { field: vec![] });
drop(x.field);
}
gives this error:
error[E0507]: cannot move out of borrowed content
--> src/main.rs:7:10
|
7 | drop(x.field);
| ^ cannot move out of borrowed content
That is confusing -- after all, x
is not borrowed!
The problem is that Rc
only implements Deref
, and hence we wind up lowering to Deref::deref(&x).field
, and deref
returns a &Bar
.
We should probably say:
error[E0507]: cannot move out of `Rc`
--> src/main.rs:7:10
|
7 | drop(x.field);
| ^ cannot move out of an `Rc`