Skip to content

Instantly share code, notes, and snippets.

@alexcrichton
Last active December 11, 2015 17:48
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 alexcrichton/4637357 to your computer and use it in GitHub Desktop.
Save alexcrichton/4637357 to your computer and use it in GitHub Desktop.
struct Foo {
foo : &int,
}
impl Foo {
fn a(&mut self) {}
}
fn main() {
let mut l = Foo { foo: &4 };
l.a();
l.a();
}
$ rustc --test foo.rs
foo.rs:12:2: 12:3 error: loan of mutable local variable as mutable conflicts with prior loan
foo.rs:12 l.a();
^
foo.rs:11:2: 11:3 note: prior loan as mutable granted here
foo.rs:11 l.a();
^
error: aborting due to previous error
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment