Skip to content

Better diagnostics when user forgets to wrap code in main function #71901

Open
@frewsxcv

Description

@frewsxcv
// some_third_party_crate/lib.rs

mod some_third_party_crate {
    pub fn show() {}
}

//////////////////////////////////////////
//////////////////////////////////////////
//////////////////////////////////////////

// main.rs

some_third_party_crate::show();

https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=8fca04bfa35f22c6776578d6c9fd8fbc

Screen Shot 2020-05-04 at 5 46 43 PM

We should suggest the user wrap their code in fn main() { ... }

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.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