Description
Given the following code: https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=513388a632de3de69d34c0ced0483ec6
fn main() {
let x = 5;
println!("The value of x is: {}", x);
x = 6;
println!("The value of x is: {}", x);
}
The current output is:
...
| help: make this binding mutable: `mut x`
...
Ideally the output should look like:
...
| help: consider making this binding mutable: `mut x`
...
Maybe it's over-analyzing the messaging, but in a lot of cases we make suggestions from compiler help messages - i.e. consider doing x
. That suggests the programmer should take a moment to think of alternatives before continuing.
The current message regarding mutable variables seems quite direct, as if it might be the only solution. Perhaps in some cases it will be, but encouraging use of immutable variables is probably - generally - a good thing.
One drawback with this suggestion would be that it is less concise. That means slightly more overhead as people read and understand the message.