This is a fair point. My preferred solution would be warn-by-default, similar to unused_mut
. Still, even from a didactic POV I think there's still something to be said for putting errors in the right category. Pattern mut
is effectively a lint: it doesn't break type analysis and leaving it off is not necessarily (or usually, in my experience) a bug. There exist deny-by-default lints that are more serious (overflowing_literals
, for example, is always a bug; mutable_transmutes
is always a soundness bug). Missing mut
cannot cause a bug.
I also don't agree that the option to downgrade a lint makes the situation worse. Again, my preference would be for it to be a warning, but the effect of making it deny-by-default is essentially the same as the current situation, except it leaves open the possibility of converting it to a warning.
In my estimation, that's the situation we are in right now: pattern mut
is already technically totally irrelevant, and I don't understand (rhetorically speaking) why the compiler cares so much about it to conflate it with &mut
, which is an extremely useful and orthogonal feature that preserves memory safety. Or, at least, if it is important to conflate these two things, why does &mut T
get to slip through the DerefMut
loophole?
(Incidentally, Traits and patterns in functions without body? - The Rust Programming Language Forum is a convenient and timely example of a person being confused about exactly the difference between &mut
and pattern mut
.)