diff options
| author | Isaac van Bakel <ivb@vanbakel.io> | 2017-08-01 22:06:26 +0100 |
|---|---|---|
| committer | Isaac van Bakel <ivb@vanbakel.io> | 2017-08-01 23:01:25 +0100 |
| commit | bb578b6e1214e3b8efea96f6c97f8743fb33b613 (patch) | |
| tree | eef0b8354efd3ed4800869f11b6c7f16e54a0e7c | |
| parent | d817d58fe433da78c8ff942f3fdee4003c3e595d (diff) | |
| download | rust-bb578b6e1214e3b8efea96f6c97f8743fb33b613.tar.gz rust-bb578b6e1214e3b8efea96f6c97f8743fb33b613.zip | |
Added tests for bugs fixed.
| -rw-r--r-- | src/test/compile-fail/lint-unused-mut-variables.rs | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/test/compile-fail/lint-unused-mut-variables.rs b/src/test/compile-fail/lint-unused-mut-variables.rs index 21cfadb9c79..49ba9421d65 100644 --- a/src/test/compile-fail/lint-unused-mut-variables.rs +++ b/src/test/compile-fail/lint-unused-mut-variables.rs @@ -47,6 +47,20 @@ fn main() { let x = |mut y: isize| 10; //~ ERROR: variable does not need to be mutable fn what(mut foo: isize) {} //~ ERROR: variable does not need to be mutable + let mut a = &mut 5; //~ ERROR: variable does not need to be mutable + *a = 4; + + let mut a = 5; + let mut b = (&mut a,); + *b.0 = 4; //~^ ERROR: variable does not need to be mutable + + fn mut_ref_arg(mut arg : &mut [u8]) -> &mut [u8] { + &mut arg[..] //~^ ERROR: variable does not need to be mutable + } + + let mut v : &mut Vec<()> = &mut vec![]; //~ ERROR: variable does not need to be mutable + v.push(()); + // positive cases let mut a = 2; a = 3; |
