Skip to content

All callable types could have better error messages in the "no method found" case to suggest that you may have forgotten to actually call them #29124

Closed
@bstrie

Description

@bstrie

Taking a real-life example from #rust today:

fn main() {
    let mut guess = String::new();
    std::io::stdin.read_line(&mut guess);
}

Yields the following error message:

<anon>:3:20: 3:41 error: no method named `read_line` found for type `fn() -> std::io::stdio::Stdin {std::io::stdio::stdin}` in the current scope
<anon>:3     std::io::stdin.read_line(&mut guess);
                            ^~~~~~~~~~~~~~~~~~~~~

The problem is that the code should read stdin().read_line rather than stdin.read_line, but the error message only hints at that. How hard would it be to add a note to all "no method found" errors when the type is callable?

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsE-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.E-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