rust/src/test/compile-fail/ret-by-reference-safety-2.rs
2011-09-15 16:37:37 +02:00

13 lines
232 B
Rust

// error-pattern:overwriting x will invalidate reference a
fn f(a: {x: {mutable x: int}}) -> &{mutable x: int} {
ret a.x;
}
fn main() {
let x = {x: {mutable x: 4}};
let &a = f(x);
x = {x: {mutable x: 5}};
a;
}