rust/src/test/run-fail/borrowck-wg-imm-then-mut.rs

20 lines
247 B
Rust
Raw Normal View History

2013-05-05 21:05:37 -04:00
// error-pattern:borrowed
// Test that if you imm borrow then mut borrow it fails.
fn add1(a:@mut int)
{
add2(a); // already frozen
}
fn add2(_:&mut int)
{
}
pub fn main()
{
let a = @mut 3;
let b = &*a; // freezes a
add1(a);
}