]> git.lizzy.rs Git - rust.git/blob - src/librustc_error_codes/error_codes/E0308.md
Rollup merge of #62514 - stephaneyfx:box-ffi, r=nikomatsakis
[rust.git] / src / librustc_error_codes / error_codes / E0308.md
1 This error occurs when the compiler was unable to infer the concrete type of a
2 variable. It can occur for several cases, the most common of which is a
3 mismatch in the expected type that the compiler inferred for a variable's
4 initializing expression, and the actual type explicitly assigned to the
5 variable.
6
7 For example:
8
9 ```compile_fail,E0308
10 let x: i32 = "I am not a number!";
11 //     ~~~   ~~~~~~~~~~~~~~~~~~~~
12 //      |             |
13 //      |    initializing expression;
14 //      |    compiler infers type `&str`
15 //      |
16 //    type `i32` assigned to variable `x`
17 ```