Skip to content

missing fn before main() -- error could be improved #65381

Closed
@ultrasaurus

Description

@ultrasaurus

As a newcomer to Rust, sometimes I forget fn before main() and the error message doesn't make sense in this instance:

Example file:

main() {
}

Error message

error: expected one of `!` or `::`, found `(`
 --> examples/tuple.rs:1:5
  |
1 | main() {
  |     ^ expected one of `!` or `::` here

suggested change:

"^ expected prior fn for a function declaration or suffix ! for a macro"

I'm not familiar with a case where :: would make sense here without other changes too.

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.D-newcomer-roadblockDiagnostics: Confusing error or lint; hard to understand for new users.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