Skip to content

Suggestion: Syntax errors for malformed extern statements could be clearer #25468

Closed
@Wilfred

Description

@Wilfred

This is a very minor bit of polish, but I bumped into it. Given the following syntactically invalid code:

extern crte hyper;

fn main() {
    println!("hello world")
}

rustc produces the error:

$ rustc foo.rs
foo.rs:1:8: 1:12 error: expected `{` or `fn`, found `crte`
foo.rs:1 extern crte hyper;
                ^~~~

Ideally, the syntax error message would suggest crate in this instance too.

Whilst there are other tokens that can occur after extern (such as strings), I think crate is sufficiently common to warrant an explicit mention.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions