Closed
Description
This program fails to compile:
struct A<'a> { b: &'a mut int }
fn foo(a: &A) {
*a.b = 3;
}
fn main() {
let mut a = 2;
let b = A { b: &mut a };
foo(&b);
}
whereas this program succeeds to compile
struct A<'a> { b: &'a mut int }
fn bar(a: &mut int) { *a = 2; }
fn foo(a: &A) {
bar(a.b);
bar(a.b);
}
fn main() {
let mut a = 2;
let b = A { b: &mut a };
foo(&b);
}
These seem to be doing the same thing to me, so I would expect both of them to be rejected or both of them be accepted.
Metadata
Metadata
Assignees
Labels
No labels