Closed
Description
This code:
fn main() {
let bar = &5;
foo(&*bar);
}
fn foo(x: &mut int) -> &int {
x
}
Gives this error message:
hello.rs:3:9: 3:14 error: cannot borrow immutable dereference of `&`-pointer as mutable
hello.rs:3 foo(&*bar);
^~~~~
This error is correct, but is really complicated. First of all, &pointer
should probably use 'reference,' the term we've settled on for &T
. More importantly, it's just a very dense sentence. This came up in IRC this morning.