Closed
Description
use serde::Deserialize;
#[derive(Deserialize)]
struct S {}
fn f() -> Result<i8, ()> {
1
}
fn main() {
println!("Hello, world!");
}
The current output is:
error[E0308]: mismatched types
--> src/main.rs:7:5
|
6 | fn f() -> Result<i8, ()> {
| -------------- expected `Result<i8, ()>` because of return type
7 | 1
| ^
| |
| expected enum `Result`, found integer
| help: try using a variant of the expected enum: `_::_serde::__private::Ok(1)`
|
= note: expected enum `Result<i8, ()>`
found type `{integer}`
Ideally the output should look like:
error[E0308]: mismatched types
--> src/main.rs:7:5
|
6 | fn f() -> Result<i8, ()> {
| -------------- expected `Result<i8, ()>` because of return type
7 | 1
| ^
| |
| expected enum `Result`, found integer
| help: try using a variant of the expected enum: `Ok(1)`
|
= note: expected enum `Result<i8, ()>`
found type `{integer}`
The bug exists on stable 1.56.1 and current nightly 2021-11-16.