rust/src/test/run-fail/borrowck-wg-one-mut-one-imm-slices.rs
2013-07-24 09:45:20 -04:00

17 lines
263 B
Rust

// error-pattern:borrowed
// Test that write guards trigger when arguments are coerced to slices.
fn add(x:&mut [int], y:&[int])
{
x[0] = x[0] + y[0];
}
pub fn main()
{
let z = @mut [1,2,3];
let z2 = z;
add(z, z2);
printfln!("%d", z[0]);
}