rust/src/test/compile-fail/regions-infer-borrow-scope-too-big.rs

15 lines
209 B
Rust
Raw Normal View History

2012-07-06 11:14:57 -05:00
type point = {x: int, y: int};
fn x_coord(p: &point) -> &int {
ret &p.x;
}
fn foo(p: @point) -> &int {
let xc = x_coord(p); //~ ERROR illegal borrow
2012-07-06 11:14:57 -05:00
assert *xc == 3;
ret xc;
2012-07-06 11:14:57 -05:00
}
fn main() {}