]> git.lizzy.rs Git - rust.git/blob - src/librustc_error_codes/error_codes/E0308.md
Rollup merge of #70038 - DutchGhost:const-forget-tests, r=RalfJung
[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 was unable to infer the concrete type of a
16 variable. It can occur for several cases, the most common of which is a
17 mismatch in the expected type that the compiler inferred for a variable's
18 initializing expression, and the actual type explicitly assigned to the
19 variable.