Skip to content

Confusing type inference error span #85586

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

Closed
Sejsel opened this issue May 22, 2021 · 0 comments · Fixed by #85971
Closed

Confusing type inference error span #85586

Sejsel opened this issue May 22, 2021 · 0 comments · Fixed by #85971
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

@Sejsel
Copy link

Sejsel commented May 22, 2021

Given the following code (playground):

fn main() {
    let a = [1, 2, 3].iter().sum();
    let b = (a + 1) as usize;
}

The current output is:

error[E0282]: type annotations needed
 --> src/main.rs:3:13
  |
3 |     let b = (a + 1) as usize;
  |             ^^^^^^^^^^^^^^^^ cannot infer type
  |
  = note: type must be known at this point

Ideally the output should look like:

error[E0282]: type annotations needed
 --> src/main.rs:3:13
  |
3 |     let b = (a + 1) as usize;
  |             ^^^^^^^ cannot infer type
  |
  = note: type must be known at this point

Happens on both stable 1.52.1 and nightly 1.54.

@Sejsel Sejsel 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 May 22, 2021
@bors bors closed this as completed in f3f8e75 Jul 30, 2021
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

Successfully merging a pull request may close this issue.

1 participant