-
Notifications
You must be signed in to change notification settings - Fork 13.5k
Closed
Labels
A-NLLArea: Non-lexical lifetimes (NLL)Area: Non-lexical lifetimes (NLL)A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsC-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.NLL-diagnosticsWorking towards the "diagnostic parity" goalWorking towards the "diagnostic parity" goalT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Milestone
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`
Metadata
Metadata
Assignees
Labels
A-NLLArea: Non-lexical lifetimes (NLL)Area: Non-lexical lifetimes (NLL)A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsC-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.NLL-diagnosticsWorking towards the "diagnostic parity" goalWorking towards the "diagnostic parity" goalT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.