rust/src/test/compile-fail/mutable-arguments.rs
Tim Chevalier e16dbb7888 Demode some code using by-mutbl-ref; warn about by-mutbl-ref
The parser now warns about use of mutbl-ref mode, though it's kind
of a lie since this commit doesn't remove support for the mode.

Changed move_val_init to have stage0 and stage1/2 versions, the latter of
which is demoded.

Changed the type that the typechecker expects the move_val_init
intrinsic to have. After this is pushed, I can make a new snapshot,
which will remove the need for the stage0 versions.
2012-10-05 15:37:01 -07:00

30 lines
694 B
Rust

// Note: it would be nice to give fewer warnings in these cases.
fn mutate_by_mut_ref(x: &mut uint) {
*x = 0;
}
fn mutate_by_ref(&&x: uint) {
//~^ WARNING unused variable: `x`
x = 0; //~ ERROR assigning to argument
}
fn mutate_by_val(++x: uint) {
//~^ WARNING unused variable: `x`
x = 0; //~ ERROR assigning to argument
}
fn mutate_by_copy(+x: uint) {
//~^ WARNING unused variable: `x`
x = 0; //~ ERROR assigning to argument
//~^ WARNING value assigned to `x` is never read
}
fn mutate_by_move(-x: uint) {
//~^ WARNING unused variable: `x`
x = 0; //~ ERROR assigning to argument
//~^ WARNING value assigned to `x` is never read
}
fn main() {
}