E0092
ErrorUnsafe fix
char literal that is not one code point
ErrorUnsafe fixA char literal holds exactly one code point. '' holds none, and 'ab' holds two. An e followed by a combining accent between the quotes is two code points too, however it looks on the screen. Text is a string, written in double quotes: "ab".
Why
A char is one Unicode scalar value, not what a reader sees as one character. Single quotes around text are a string in some languages, so the report offers double quotes as an unsafe fix, unless the text holds ", { or }, which a string reads differently.
Broken
fn main() {
let c = 'ab'
print(c)
}
What sisu says
error[E0092]: a `char` holds one code point --> E0092.sisu:2:13 | 2 | let c = 'ab' | ^^^^ | help: if you meant a string, write it in double quotes | 2 - let c = 'ab' 2 + let c = "ab" | sisu: 1 error sisu: for more on a code, run `sisu explain <code>`: E0092
Fixed
fn main() {
let c = 'a'
print(c)
}
Sisu