-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Labels
A-NLLArea: Non-lexical lifetimes (NLL)Area: Non-lexical lifetimes (NLL)NLL-diagnosticsWorking towards the "diagnostic parity" goalWorking towards the "diagnostic parity" goal
Description
struct Sheep {
message: String
}
impl Sheep {
fn talk(self) {
println!("{}", self.message);
}
}
fn main()
{
let sheep = &Sheep { message: "Määh".into() };
sheep.talk();
}
Errors:
Compiling playground v0.0.1 (/playground)
error[E0507]: cannot move out of borrowed content
--> src/main.rs:14:5
|
14 | sheep.talk();
| ^^^^^ cannot move out of borrowed content
error[E0507]: cannot move out of `*sheep` which is behind a `&` reference
--> src/main.rs:14:5
|
13 | let sheep = &Sheep { message: "Määh".into() };
| --------------------------------- help: consider changing this to be a mutable reference: `&mut Sheep { message: "Määh".into() }`
14 | sheep.talk();
| ^^^^^
| |
| cannot move out of `*sheep` which is behind a `&` reference
| `sheep` is a `&` reference, so the data it refers to cannot be moved
error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0507`.
error: Could not compile `playground`.
To learn more, run the command again with --verbose.
Metadata
Metadata
Assignees
Labels
A-NLLArea: Non-lexical lifetimes (NLL)Area: Non-lexical lifetimes (NLL)NLL-diagnosticsWorking towards the "diagnostic parity" goalWorking towards the "diagnostic parity" goal
Type
Projects
Milestone
Relationships
Development
Select code repository
Activity
matthewjasper commentedon Oct 17, 2018
cc #53004
Auto merge of #55221 - matthewjasper:fewer-duplicate-migrate-messages…
Rollup merge of rust-lang#55221 - matthewjasper:fewer-duplicate-migra…