I ran across this behavior when I had moved a constant outside the module and didn't get the diagnostic I was expecting. It was something like this:
// const MISSING_CONST: &str = "foo"; fn main() { let bar = Some("bar"); matches!(bar, Some(MISSING_CONST)); // returns true, accepting any value in Some() } I expected the matches! to not allow an unused binding I guess, or at least warn.
Constant-like bindings are similarly addressed here. I wonder if we could at least make it a different warning if the binding is ALL_CAPS because the compiler seems to already draw a distinction, demarking ALL_CAPS as reserved for constants.
4 posts - 3 participants

