rust/src/test/compile-fail/mutable-arguments.rs
Niko Matsakis f90228b8a8 make all arguments modes immutable
note: you can still move from copy/move mode args
2012-05-29 16:22:17 -07:00

31 lines
694 B
Rust

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