Skip to content

Inconsistent behaviour & peculiar error messages for extern "Rust" fn main() #10764

Closed
@huonw

Description

@huonw
extern "C" fn main() {}

gives

extern-rust.rs:1:0: 1:23 error: main function expects type: `fn()`: expected "Rust" fn but found "C" fn
extern-rust.rs:1 extern "C" fn main() {}
                 ^~~~~~~~~~~~~~~~~~~~~~~

but changing the "C" to a "Rust" as the error message implies might work gives

extern-rust.rs:1:0: 1:26 error: main function expects type: `fn()`: expected impure fn but found extern fn
extern-rust.rs:1 extern "Rust" fn main() {}
                 ^~~~~~~~~~~~~~~~~~~~~~~~~~

which is peculiar because it doesn't pass the entry-point-type-checker (although it'd hit #10763 even if it did), and it mentions impure fn even though this is now essentially a historical implementation detail of the AST (after the removal of pure fn).

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lints

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions