From d1fffd8685748357a079711dde1ae22560c6cd70 Mon Sep 17 00:00:00 2001 From: Isaac van Bakel Date: Sun, 6 Aug 2017 18:25:31 +0100 Subject: [PATCH] Added closure test case. --- src/test/compile-fail/lint-unused-mut-variables.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/test/compile-fail/lint-unused-mut-variables.rs b/src/test/compile-fail/lint-unused-mut-variables.rs index 49ba9421d65f..26d00755da33 100644 --- a/src/test/compile-fail/lint-unused-mut-variables.rs +++ b/src/test/compile-fail/lint-unused-mut-variables.rs @@ -54,6 +54,12 @@ fn main() { let mut b = (&mut a,); *b.0 = 4; //~^ ERROR: variable does not need to be mutable + let mut x = &mut 1; //~ ERROR: variable does not need to be mutable + let mut f = || { + *x += 1; + }; + f(); + fn mut_ref_arg(mut arg : &mut [u8]) -> &mut [u8] { &mut arg[..] //~^ ERROR: variable does not need to be mutable }