]> git.lizzy.rs Git - rust.git/blob - compiler/rustc_error_codes/src/error_codes/E0308.md
e2c40f03019c1e52db80b89a3aebc0084cf1ede1
[rust.git] / compiler / rustc_error_codes / src / error_codes / E0308.md
1 Expected type did not match the received type.
2
3 Erroneous code example:
4
5 ```compile_fail,E0308
6 let x: i32 = "I am not a number!";
7 //     ~~~   ~~~~~~~~~~~~~~~~~~~~
8 //      |             |
9 //      |    initializing expression;
10 //      |    compiler infers type `&str`
11 //      |
12 //    type `i32` assigned to variable `x`
13 ```
14
15 This error occurs when the compiler is unable to infer the concrete type of a
16 variable. It can occur in several cases, the most common being a mismatch
17 between two types: the type the author explicitly assigned, and the type the
18 compiler inferred.