Skip to content

Mistyping <> in return value for () could have better error message #18945

Closed
@mdinger

Description

@mdinger

This errors but doesn't point out the problem very well:

fn fun() -> Option<int> {
    Some<7>
}
fn main(){ 
    fun();
}

The error:

<anon>:4:1: 4:2 error: unexpected token: `}`
<anon>:4 }
         ^
playpen: application terminated with error code 101

Better would be:

fn fun() -> Option<int> {
    Some<7>
    //  ^~~~~~~ These should be `()` and not`<>`
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsA-parserArea: The lexing & parsing of Rust source code to an ASTC-enhancementCategory: An issue proposing an enhancement or a PR with one.E-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.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