summaryrefslogtreecommitdiffstats
path: root/tests/ui/suggestions/type-mismatch-byte-literal.rs
blob: 34199f8c37c101d2d7236a45ece953407427910d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
// Tests that a suggestion is issued for type mismatch errors when a
// u8 is expected and a char literal which is ASCII is supplied.

fn foo(_t: u8) {}

fn main() {
    let _x: u8 = 'X';
    //~^ ERROR: mismatched types [E0308]
    //~| HELP: if you meant to write a byte literal, prefix with `b`

    foo('#');
    //~^ ERROR: mismatched types [E0308]
    //~| HELP: if you meant to write a byte literal, prefix with `b`

    // Do not issue the suggestion if the char literal isn't ASCII
    let _t: u8 = '€';
    //~^ ERROR: mismatched types [E0308]
}