Skip to content

Instantly share code, notes, and snippets.

@alexcrichton
Created February 13, 2013 21:20
Show Gist options
  • Save alexcrichton/4948417 to your computer and use it in GitHub Desktop.
Save alexcrichton/4948417 to your computer and use it in GitHub Desktop.
struct Foo {
thing: &int // errors don't happen unless this field is a borrowed pointer
}
impl Foo {
fn run(&mut self) {
self.foo();
self.bar();
}
fn bar(&mut self) {}
fn foo(&mut self) {}
}
$ rustc --test foo.rs
foo.rs:8:4: 8:8 error: loan of dereference of mutable & pointer as mutable conflicts with prior loan
foo.rs:8 self.bar();
^~~~
foo.rs:7:4: 7:8 note: prior loan as mutable granted here
foo.rs:7 self.foo();
^~~~
error: aborting due to previous error
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment