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

Confusing error message with str::parse #70065

Open
Aaron1011 opened this issue Mar 17, 2020 · 1 comment
Open

Confusing error message with str::parse #70065

Aaron1011 opened this issue Mar 17, 2020 · 1 comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints C-enhancement Category: An issue proposing an enhancement or a PR with one. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@Aaron1011
Copy link
Member

The following code:

fn bar() -> Result<(), std::num::ParseIntError> {
    let a = "Hello".parse()?;
    Ok(())
}

fn main() {}

gives the following error message:

error[E0277]: the trait bound `(): std::str::FromStr` is not satisfied
 --> src/main.rs:2:21
  |
2 |     let a = "Hello".parse()?;
  |                     ^^^^^ the trait `std::str::FromStr` is not implemented for `()`

error: aborting due to previous error

The bound (): std::str::FromStr appears seemingly out of thin air. We should explain where the type () and trait std::str::FromStr come from.

The () appears to be produced by never-type fallback, which was quite surprising to me.

@Aaron1011 Aaron1011 added the C-bug Category: This is a bug. label Mar 17, 2020
@jonas-schievink jonas-schievink 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. C-enhancement Category: An issue proposing an enhancement or a PR with one. and removed C-bug Category: This is a bug. labels Mar 17, 2020
@fmease
Copy link
Member

fmease commented Aug 30, 2024

Triage 2024:
Keyword is type inference fallback.
In the 2024 edition, this will change to ! from () but otherwise the diagnostic issue continues to persist.
CC related #113875

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 C-enhancement Category: An issue proposing an enhancement or a PR with one. 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

3 participants