Skip to content

Custom errors for well-known traits #20783

Closed
@nikomatsakis

Description

@nikomatsakis

Consider these comments by the one and only @steveklabnik:

[17:20:10] <steveklabnik> ugh
[17:20:19] <steveklabnik> so close to getting this to compile
[17:20:21] <steveklabnik> and i am rewarded with
[17:20:27] <steveklabnik>  error: the trait `core::iter::FromIterator<core::result::Result<(collections::vec::Vec<usize>, collections::string::String), std::sync::mpsc::RecvError>>` is not implemented
                          for the type `collections::vec::Vec<(collections::vec::Vec<usize>, collections::string::String)>`
[17:20:31] <steveklabnik> O_O
[17:21:01] <steveklabnik> that one is easy i guess
[17:21:04] <steveklabnik> just a scary message

wouldn't it be nicer if the compiler saw that error involved FromIterator and printed something like "the type you are iterating over doesn't match the expected type of the collection you are creating"?

Nominating for 1.0 (not beta), because this could be a big usability benefit. I'm sure there are other "well-known" traits we could do this for.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsE-mentorCall for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions