Skip to content

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

Open

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() { ... }

Activity

  1. added
    C-bugCategory: This is a bug.
    A-diagnosticsArea: Messages for errors, warnings, and lints
    and removed
    C-bugCategory: This is a bug.
    on May 4, 2020
  2. added
    A-parserArea: The lexing & parsing of Rust source code to an AST
    C-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.
    on May 4, 2020
  3. petrochenkov commented on May 4, 2020

    @petrochenkov
    Contributor
  4. frewsxcv commented on May 16, 2022

    @frewsxcv
    ContributorAuthor

    Triage: no change here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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