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

Recent regression in diagnostics ("trait Sized must be implemented" error message) #18040

Closed
japaric opened this issue Oct 14, 2014 · 2 comments

Comments

@japaric
Copy link
Member

japaric commented Oct 14, 2014

(Sorry for the poor title, feel free to change it)

STR

use std::collections::HashMap;

fn main() {
    let arr = [(1i, 1u), (2, 2), (3, 3)];

    let m: HashMap<_, _> = arr.iter().collect();
    //                               ^~ forgot `.map(|&x| x)`
}

Error message

collect.rs:6:12: 6:25 error: unable to infer enough type information to locate the impl of the trait `core::kinds::Sized` for the type `<generic #2>`; type annotations required
collect.rs:6     let m: HashMap<_, _> = arr.iter().collect();
                        ^~~~~~~~~~~~~
collect.rs:6:12: 6:25 note: the trait `core::kinds::Sized` must be implemented because it is required by `std::collections::hashmap::map::HashMap`
collect.rs:6     let m: HashMap<_, _> = arr.iter().collect();
                        ^~~~~~~~~~~~~
error: aborting due to previous error

Compare it with the error reported with Rust 0.12:

<anon>:6:28: 6:48 error: type mismatch: the type `std::collections::hashmap::map::HashMap<<generic #2>,<generic #3>>` implements the trait `core::iter::FromIterator<(<generic #220>,<generic #221>)>`, but the trait `core::iter::FromIterator<&(int,uint)>` is required (expected &-ptr, found tuple)
<anon>:6     let m: HashMap<_, _> = arr.iter().collect();
                                    ^~~~~~~~~~~~~~~~~~~~
error: aborting due to previous error

Much better!

Version

rustc 0.13.0-dev (a1e2eb039 2014-10-14 04:02:48 +0000)

I thought this was the same as #17567, but the confusing error on #17567 also occurs with 0.12, which means that the issue reported here has been introduced more recently.

cc @nikomatsakis

@conradkleinespel
Copy link
Contributor

I've seen similar compile time errors since upgrading to 0.13.0. Here's a recently failed build of a library I'm working on:
https://travis-ci.org/conradkleinespel/rustastic-smtp/builds/38429831

Not sure how to help Rust maintainers with this. Is there anything special we can do ?

@nrc
Copy link
Member

nrc commented Oct 23, 2014

dup of #17567 and #17849 (which all come down to needing a better error message here)

@bors bors closed this as completed in 737e396 Oct 31, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants