Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rustc suggests _::_serde::__private::Ok(1) instead of Ok(1) #90982

Closed
jendrikw opened this issue Nov 17, 2021 · 5 comments
Closed

rustc suggests _::_serde::__private::Ok(1) instead of Ok(1) #90982

jendrikw opened this issue Nov 17, 2021 · 5 comments
Labels
A-diagnostics Area: Messages for errors, warnings, and lints T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@jendrikw
Copy link
Contributor

Given the following code: https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&code=use%20serde%3A%3ADeserialize%3B%0A%0A%23%5Bderive(Deserialize)%5D%0Astruct%20S%20%7B%7D%0A%0Afn%20f()%20-%3E%20Result%3Ci8%2C%20()%3E%20%7B%0A%20%20%20%201%0A%7D%0A%0Afn%20main()%20%7B%0A%20%20%20%20println!(%22Hello%2C%20world!%22)%3B%0A%7D

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.

@jendrikw jendrikw added A-diagnostics Area: Messages for errors, warnings, and lints T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Nov 17, 2021
@jendrikw
Copy link
Contributor Author

Seems related to #21934.

@jyn514
Copy link
Member

jyn514 commented Nov 18, 2021

This should be fixed by #87349.

@Kampfkarren
Copy link
Contributor

#87349 was closed and this is still an issue.

@TDecking
Copy link
Contributor

This seems to be fixed as of version 1.63.

@jendrikw
Copy link
Contributor Author

Can confirm it's fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

4 participants