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

Incorrect error order for println! #78568

Open
pickfire opened this issue Oct 30, 2020 · 1 comment
Open

Incorrect error order for println! #78568

pickfire opened this issue Oct 30, 2020 · 1 comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-inference Area: Type inference C-enhancement Category: An issue proposing an enhancement or a PR with one. D-confusing Diagnostics: Confusing error or lint that should be reworked. D-incorrect Diagnostics: A diagnostic that is giving misleading or incorrect information. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@pickfire
Copy link
Contributor

pickfire commented Oct 30, 2020

I tried this code:

fn main() {
    let guess = "123";
    let guess = match guess.trim().parse() {
        Ok(num) => num + 1,
        Err(_) => todo!(),
    };
    println!("guess: {}", guess);
}

I expected to see this happen:

  |
4 |         Ok(num) => num + 1,
  |            ^^^ cannot infer type
  |
help: consider specifying the type argument in the method call
  |
3 |     let guess = match guess.trim().parse::<F>() {
  |                                         ^^^^^

Instead, this happened:

  |
7 |     println!("guess: {}", guess);
  |                           ^^^^^ `()` cannot be formatted with the default formatter
  |
  = help: the trait `std::fmt::Display` is not implemented for `()`
  = note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead
  = note: required by `std::fmt::Display::fmt`
  = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

But eventually I will be able to see that once I use {:?} but users need to do an extra step to see the other warning.

Meta

rustc --version --verbose: stable 1.47.0 to nightly 1.49.0-nightly (2020-10-29 6bdae9e)

stable 1.47.0 to nightly 1.49.0-nightly (2020-10-29 6bdae9edd0cc099daa60)
@pickfire pickfire added the C-bug Category: This is a bug. label Oct 30, 2020
@pickfire pickfire changed the title Incorrect error order Incorrect error order for println! Oct 30, 2020
@JohnTitor JohnTitor added A-diagnostics Area: Messages for errors, warnings, and lints C-enhancement Category: An issue proposing an enhancement or a PR with one. D-confusing Diagnostics: Confusing error or lint that should be reworked. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. and removed C-bug Category: This is a bug. labels Oct 30, 2020
@camelid camelid added D-incorrect Diagnostics: A diagnostic that is giving misleading or incorrect information. A-inference Area: Type inference labels Oct 30, 2020
@estebank
Copy link
Contributor

CC #38508.

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 A-inference Area: Type inference C-enhancement Category: An issue proposing an enhancement or a PR with one. D-confusing Diagnostics: Confusing error or lint that should be reworked. D-incorrect Diagnostics: A diagnostic that is giving misleading or incorrect information. 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