Skip to content

inform user where to give a type annotation after a call to collect #47777

Closed
@nikomatsakis

Description

@nikomatsakis

UPDATE: Mentoring instructions below.


We are not giving a very good error message in this example:

fn main() {
    let mut dirty_list = (0..5).collect();
    dirty_list.pop();
}

We say:

error[E0619]: the type of this value must be known in this context
 --> src/main.rs:3:5
  |
3 |     dirty_list.pop();
  |     ^^^^^^^^^^^^^^^^

It'd be nice if we at least informed the user that they ought to annotate the type of dirty_list. (Indeed, I know we used to have a bug on this, and I thought we were doing so...?)

It'd be nicer still if we recognized that there is a call to collect and were able to say something like "you need to specify the kind of collection".

cc @estebank

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsC-enhancementCategory: An issue proposing an enhancement or a PR with one.E-mentorCall for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions