1 {"message":"mismatched types","code":{"code":"E0308","explanation":"Expected type did not match the received type.
3 Erroneous code examples:
6 fn plus_one(x: i32) -> i32 {
10 plus_one(\"Not a number\");
11 // ^^^^^^^^^^^^^^ expected `i32`, found `&str`
14 // ^^^^^^^^^^^^ expected `bool`, found `&str`
17 let x: f32 = \"Not a float\";
18 // --- ^^^^^^^^^^^^^ expected `f32`, found `&str`
20 // expected due to this
23 This error occurs when an expression was used in a place where the compiler
24 expected an expression of a different type. It can occur in several cases, the
25 most common being when calling a function and passing an argument which has a
26 different type than the matching type in the function declaration.
27 "},"level":"error","spans":[{"file_name":"$DIR/flag-json.rs","byte_start":244,"byte_end":246,"line_start":7,"line_end":7,"column_start":17,"column_end":19,"is_primary":true,"text":[{"text":" let _: () = 42;","highlight_start":17,"highlight_end":19}],"label":"expected `()`, found integer","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"$DIR/flag-json.rs","byte_start":239,"byte_end":241,"line_start":7,"line_end":7,"column_start":12,"column_end":14,"is_primary":false,"text":[{"text":" let _: () = 42;","highlight_start":12,"highlight_end":14}],"label":"expected due to this","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":"error[E0308]: mismatched types
28 --> $DIR/flag-json.rs:7:17
31 | -- ^^ expected `()`, found integer
33 | expected due to this
36 {"message":"aborting due to previous error","code":null,"level":"error","spans":[],"children":[],"rendered":"error: aborting due to previous error
39 {"message":"For more information about this error, try `rustc --explain E0308`.","code":null,"level":"failure-note","spans":[],"children":[],"rendered":"For more information about this error, try `rustc --explain E0308`.