]> git.lizzy.rs Git - rust.git/blob - src/librustc_error_codes/error_codes/E0308.md
Rollup merge of #72674 - Mark-Simulacrum:clippy-always-test-pass, r=oli-obk
[rust.git] / src / librustc_error_codes / 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.