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

Error message blames wrong line #66923

Closed
vchekan opened this issue Dec 1, 2019 · 0 comments · Fixed by #67354
Closed

Error message blames wrong line #66923

vchekan opened this issue Dec 1, 2019 · 0 comments · Fixed by #67354
Labels
A-collections Area: std::collections. A-diagnostics Area: Messages for errors, warnings, and lints A-iterators Area: Iterators C-bug Category: This is a bug. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@vchekan
Copy link

vchekan commented Dec 1, 2019

The code below blames the last line for the error where in fact error is in the previous one.
The error message makes no sense because x4 type is specified explicitly and no iterator is present anymore.

fn main() {
    let v = vec![1_f64, 2.2_f64];
    let mut fft: Vec<Vec<f64>> = vec![];

    let x1: &[f64] = &v;
    let x2 = x1.into_iter();
    let x3 = x2.rev();
    let x4: Vec<f64> = x3.collect();    // <-- mistake is here
    fft.push(x4);                                 // <-- but error blames this line
}
--> src/main.rs:9:14
  |
9 |     fft.push(x4);
  |              ^^ a collection of type `std::vec::Vec<f64>` cannot be built from `std::iter::Iterator<Item=&f64>`
@jonas-schievink jonas-schievink added A-diagnostics Area: Messages for errors, warnings, and lints C-bug Category: This is a bug. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. A-collections Area: std::collections. A-iterators Area: Iterators labels Dec 1, 2019
JohnTitor added a commit to JohnTitor/rust that referenced this issue Dec 5, 2019
Fix pointing at arg when cause is outside of call

Closes: rust-lang#66923
Mark-Simulacrum added a commit to Mark-Simulacrum/rust that referenced this issue Dec 19, 2019
Fix pointing at arg when cause is outside of call

Follow up after: rust-lang#66933

Closes: rust-lang#66923

r? @estebank
Centril added a commit to Centril/rust that referenced this issue Dec 20, 2019
Fix pointing at arg when cause is outside of call

Follow up after: rust-lang#66933

Closes: rust-lang#66923

r? @estebank
@bors bors closed this as completed in 5a8083c Dec 20, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-collections Area: std::collections. A-diagnostics Area: Messages for errors, warnings, and lints A-iterators Area: Iterators C-bug Category: This is a bug. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
2 participants