1
Fork 0

Test for mut in ident patterns.

This commit is contained in:
Luqman Aden 2013-10-22 23:51:45 -04:00
parent 99b7662971
commit f5e64aeb41
3 changed files with 115 additions and 0 deletions

View file

@ -20,6 +20,14 @@ fn main() {
let mut a = 2; //~ ERROR: variable does not need to be mutable
let mut b = 3; //~ ERROR: variable does not need to be mutable
let mut a = ~[3]; //~ ERROR: variable does not need to be mutable
let (mut a, b) = (1, 2); //~ ERROR: variable does not need to be mutable
match 30 {
mut x => {} //~ ERROR: variable does not need to be mutable
}
let x = |mut y: int| 10; //~ ERROR: variable does not need to be mutable
fn what(mut foo: int) {} //~ ERROR: variable does not need to be mutable
// positive cases
let mut a = 2;
@ -30,6 +38,17 @@ fn main() {
do callback {
a.push(3);
}
let (mut a, b) = (1, 2);
a = 34;
match 30 {
mut x => {
x = 21;
}
}
let x = |mut y: int| y = 32;
fn nothing(mut foo: int) { foo = 37; }
}
fn callback(f: &fn()) {}