Skip to content

Instantly share code, notes, and snippets.

@Dretch
Last active December 15, 2015 01:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Dretch/5183087 to your computer and use it in GitHub Desktop.
Save Dretch/5183087 to your computer and use it in GitHub Desktop.
Rustc does not like this code.
struct MyStruct {}
impl MyStruct {
fn takes_mut_self(&mut self, _x:int) {}
fn takes_self(&self) -> int { 42 }
fn also_takes_mut_self(&mut self) {
self.takes_mut_self(self.takes_self());
}
}
fn main() {}
mut-self-issues.rs:12:28: 12:32 error: loan of dereference of mutable & pointer as immutable conflicts with prior loan
mut-self-issues.rs:12 self.takes_mut_self(self.takes_self());
^~~~
mut-self-issues.rs:12:8: 12:12 note: prior loan as mutable granted here
mut-self-issues.rs:12 self.takes_mut_self(self.takes_self());
^~~~
error: aborting due to previous error
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment