]> git.lizzy.rs Git - rust.git/blob - tests/ui/suggestions/type-mismatch-byte-literal.rs
Rollup merge of #106896 - Ezrashaw:str-cast-bool-emptyness, r=compiler-errors
[rust.git] / tests / ui / suggestions / type-mismatch-byte-literal.rs
1 // Tests that a suggestion is issued for type mismatch errors when a
2 // u8 is expected and a char literal which is ASCII is supplied.
3
4 fn foo(_t: u8) {}
5
6 fn main() {
7     let _x: u8 = 'X';
8     //~^ ERROR: mismatched types [E0308]
9     //~| HELP: if you meant to write a byte literal, prefix with `b`
10
11     foo('#');
12     //~^ ERROR: mismatched types [E0308]
13     //~| HELP: if you meant to write a byte literal, prefix with `b`
14
15     // Do not issue the suggestion if the char literal isn't ASCII
16     let _t: u8 = '€';
17     //~^ ERROR: mismatched types [E0308]
18 }