E1015

E1015#

The mutability is never used. It is a common mistake to declare an array to be mutable when it is not necessary. Setting the value of an element in an array does not require the array to be mutable. For example, a[0] = 0 does not require a to be mutable, but a = [0, 1, 2] does.

Erroneous example#

fn main {
  let mut x = [1, 2, 3] // Warning: The mutability of 'x' is never used.
  x[0] = 0
  println(x)
}

Suggestion#

Remove the mut keyword from the variable declaration.

fn main {
  let x = [1, 2, 3]
  x[0] = 0
  println(x)
}