E0125
Upper-case name where no enum is expected
ErrorUnsafe fixA name that starts with an upper-case letter in a pattern names a variant, so it can stand only where the value is an enum. Where the value is an integer, a bool, a char or a string, a pattern name is a binding, and a binding starts with a lower-case letter.
Why
An upper-case name reads as a variant, perhaps misspelled, not as a new name for the value, so the compiler does not quietly bind it. The fix lower-cases the first letter. It is unsafe, since the new name may clash with another.
Broken
fn main() {
let n = match 3 {
Count => Count + 1
}
print(n)
}
What sisu says
error[E0125]: `Count` is not a variant here --> E0125.sisu:3:9 | 3 | Count => Count + 1 | ^^^^^ | = help: a binding starts with a lower-case letter help: write `count` | 3 - Count => Count + 1 3 + count => Count + 1 | sisu: 1 error sisu: for more on a code, run `sisu explain <code>`: E0125
Fixed
fn main() {
let n = match 3 {
count => count + 1
}
print(n)
}
Sisu